Q_Id
int64
337
49.3M
CreationDate
stringlengths
23
23
Users Score
int64
-42
1.15k
Other
int64
0
1
Python Basics and Environment
int64
0
1
System Administration and DevOps
int64
0
1
Tags
stringlengths
6
105
A_Id
int64
518
72.5M
AnswerCount
int64
1
64
is_accepted
bool
2 classes
Web Development
int64
0
1
GUI and Desktop Applications
int64
0
1
Answer
stringlengths
6
11.6k
Available Count
int64
1
31
Q_Score
int64
0
6.79k
Data Science and Machine Learning
int64
0
1
Question
stringlengths
15
29k
Title
stringlengths
11
150
Score
float64
-1
1.2
Database and SQL
int64
0
1
Networking and APIs
int64
0
1
ViewCount
int64
8
6.81M
15,180,320
2013-03-02T22:44:00.000
1
0
0
0
python,styles,gtk,pygtk,pygobject
15,180,684
4
false
0
1
You can change a Widget property by using the Gtk.Widget.set_property(property, value) method. property should be a string.
2
3
0
In most pygtk widget pages, they contain sections called 'Attributes', 'Properties', and 'Style Properties'. How can I change these properties and attributes?
Editing GtkWidget attributes/properties
0.049958
0
0
3,329
15,180,320
2013-03-02T22:44:00.000
4
0
0
0
python,styles,gtk,pygtk,pygobject
15,184,441
4
true
0
1
There are three ways to change properties: As in zheoffec's answer, use the set_property() function (or set_style_property() for style properties.) This function is actually not necessary in Python, but it is there for completeness because it is part of the C API. Use the props attribute. Any property that you find in the documentation can be accessed through this attribute. For example, btn1.props.label = 'StackOverflow' and btn1.props.use_underline = False. Use the getter and setter functions as frb suggests. These are also only present because they are part of the C API, but some people prefer them over the props attribute. Also, there is no guarantee that any particular property will have getter and setter functions! Usually in a well-designed C API they will be there, but it is not required. For style properties, I believe the only option is #1. For "attributes", well, these are simply Python attributes. To access the allocation attribute, use btn1.allocation.
2
3
0
In most pygtk widget pages, they contain sections called 'Attributes', 'Properties', and 'Style Properties'. How can I change these properties and attributes?
Editing GtkWidget attributes/properties
1.2
0
0
3,329
15,180,611
2013-03-02T23:24:00.000
5
1
0
0
c++,boost,boost-python
15,180,650
1
true
0
0
There are two ways to interoperate: 1) from a "Python process", call functions written in C++. Python already has a system to load dlls, they're called "extension modules". Boost.Python can compile your source to produce one. Basically you write a little wrapper to declare a function callable from Python, and the "metaprogramming" is there to do stuff like detecting what types the C++ function takes and returns, so that it can emit the right code to convert those from/to the equivalent Python types. 2) from a "C++ process", launch and control the Python interpreter. Python provides a C API to do this, and Boost.Python knows how to use it.
1
3
0
I'm a newbie to boost and one of its libraries which I can't understand it is Boost.Python. Can anyone explain me in details how does this interoperability achieved?In the documentation there only a few words about metaprogramming. P.S. I tried to look code but because of my lack of C++ knowledge I didn't understand principles. Thanks in advance
How does boost::python work?Any ideas about the realisation details?
1.2
0
0
301
15,187,345
2013-03-03T15:42:00.000
0
0
0
0
jquery,python,selenium-webdriver
22,935,427
2
false
0
0
We can Use this Funda If driver.findElements(By.id(id)).size() > 0 Then Element Present; Else Element Not Present Same Applies for Value. Please Let me know is my Funda OK or NOT.
1
0
0
I am trying to find the presence of an element by finding the length of the jquery. How can we capture the length of a webelement in a variable, so that I can check the value of the variable to make decision. Or is there any other way to accomplish the same result. I am using python, selenium webdriver and JQuery. Thanks in advance.
When using python and selenium how to find the presence of an element based on id and value
0
0
1
467
15,187,978
2013-03-03T16:46:00.000
2
0
1
0
python,django,datetime,timezone
15,188,612
1
true
0
0
That means 18:00 local time, in a place which is +1 hour from UTC (so Western Europe, for example).
1
0
0
I have a timezone aware datetime object, which, if printed contains: 2013-03-04 18:00:00+01:00. But I always fail to understand how to read them. Does this refers to 19:00 local time or to 18:00 local time?
How to read timezone datetime objects
1.2
0
0
83
15,189,056
2013-03-03T18:20:00.000
3
0
1
0
python,nlp,string-comparison,string-matching,string-parsing
15,189,643
2
false
1
0
You could use different approaches for this (and for most efficiency mix them): You could ignore everythin that is in parenthesis. Define words you automatically drop like "black", "blue" or "white". Compare the names via their Levenshtein distance and use this distance for clustering. Surface similarity (thanks to mbatchkarov)
1
2
0
I am working on a web app where I collect data about mobile phones from several websites. The problem is that websites use slightly different naming of mobile phones. For eg the websites use the following variation in names for these two mobiles: HTC One X+ (Black); HTC One X+ Black; HTC One X Plus; HTC One X Plus, black Samsung Galaxy S3 (Pebble Blue, with 16GB); Samsung Galaxy S III (Blue); Samsung Galaxy S3 I9300 16GB Pebble Blue; Samsung I9300 Galaxy S III (16 GB); Samsung Galaxy S3 (I9300), pebble blue Since I read this data off these websites using a crawler I need my program to resolve all these different strings into same product. Any ideas? If it matters, I am using python.
How to resolve two slightly different names of same product (mobile phone) in program?
0.291313
0
0
555
15,189,649
2013-03-03T19:11:00.000
1
0
1
0
python,regex,validation,unicode,non-ascii-characters
15,242,157
4
true
0
0
[^\W0-9_] works for me, when used together with re.UNICODE
2
4
0
I'm trying to validate name fields with the re module. \w doesn't match non-ascii chars such as à. It seems that in many other regex engines, the solution would have been \p{L}, but this isn't supported in python as it appears. What would be a suitable equivalent? Update: This is different from other questions around this topic, in that I'm looking for the unicode alternative to \w which isn't the one obtained using the default re.UNICODE flag (since this flag also makes \w match digits and underscores).
Python regex to match non-ascii names
1.2
0
0
2,842
15,189,649
2013-03-03T19:11:00.000
1
0
1
0
python,regex,validation,unicode,non-ascii-characters
15,238,717
4
false
0
0
Does [^\d\s_] match what you want?
2
4
0
I'm trying to validate name fields with the re module. \w doesn't match non-ascii chars such as à. It seems that in many other regex engines, the solution would have been \p{L}, but this isn't supported in python as it appears. What would be a suitable equivalent? Update: This is different from other questions around this topic, in that I'm looking for the unicode alternative to \w which isn't the one obtained using the default re.UNICODE flag (since this flag also makes \w match digits and underscores).
Python regex to match non-ascii names
0.049958
0
0
2,842
15,195,880
2013-03-04T06:34:00.000
0
0
0
0
python,qt,python-3.x,pyqt
15,195,943
3
false
0
1
You have two choices: use two labels, one with the text and one with the image. use a QPainter to draw the text over the image.
2
0
0
I have both text and image in QLabel, so setPixmap won't satisfy my requirement. As far as I know, QLabel can load image from file by setting HTML label <img src="path_to_file" />. But how can I load image from memory(e.g. QImage)? Because some images are frequently used, it may have performance problem loading the same image from file every time.
How to insert QImage(or sth like that) into QLabel?
0
0
0
1,496
15,195,880
2013-03-04T06:34:00.000
0
0
0
0
python,qt,python-3.x,pyqt
15,198,050
3
false
0
1
You can also set stylesheet for your QLabel as:- QLabel{ background-image: url(/images/button.png);
2
0
0
I have both text and image in QLabel, so setPixmap won't satisfy my requirement. As far as I know, QLabel can load image from file by setting HTML label <img src="path_to_file" />. But how can I load image from memory(e.g. QImage)? Because some images are frequently used, it may have performance problem loading the same image from file every time.
How to insert QImage(or sth like that) into QLabel?
0
0
0
1,496
15,199,028
2013-03-04T10:09:00.000
8
0
0
1
python,tornado
15,202,174
1
true
1
0
Yes, tornado calls initialize for each request. If you want to share state between requests(like db connection) - store it in self.application.
1
3
0
There'a an initialize method in tornado.web.RequestHandler class, is it called every time there's a request?
Does initialize in tornado.web.RequestHandler get called every time for a request/
1.2
0
0
1,206
15,199,448
2013-03-04T10:30:00.000
2
0
1
1
python,twisted,bittorrent,libtorrent
15,299,811
1
true
0
0
I may be able to provide answers to some of those questions. all of libtorrents logic, including networking and disk I/O is done in separate threads. So, over all, the concern of "blocking" is not that great. Assuming you mean libtorrent functions not returning immediately. Some operations are guaranteed to return immediately, functions that don't return any state or information. However, functions that do return something, must synchronize with the libtorrent main thread, and if it is under heavy load (especially when built in debug mode with invariant checks and no optimization) this synchronization may be noticeable, especially when making many of them, and often. There are ways to use libtorrent that are more asynchronous in nature, and there is an ongoing effort in minimizing the need for using functions that synchronize. For example, instead of querying the status of all torrents individually, one can subscribe to torrent status updates. Asynchronous notifications are returned via pop_alerts(). Whether it would interfere with twisted's epoll; I can't say for sure, but it doesn't seem very likely. I don't think there's much need to interact with libtorrent via another layer of threads, since all of the work is already done in separate threads.
1
4
0
I am looking into building a multi-protocol application using twisted. One of those protocols is bittorrent. Since libtorrent is a fairly complete implementation and its python bindings seems to be a good choice. Now the question is: When using libtorrent with twisted, do I need to worry about blocking? Does the libtorrent networking layer (using boost.asio, a async networking loop) interfere with twisted epoll in any way? Should I perhaps run the libtorrent session in a thread or target a multi-process application design?
Twisted and libtorrent - do I need to worry about blocking?
1.2
0
0
370
15,200,560
2013-03-04T11:32:00.000
8
0
0
0
python,c,math
15,200,968
2
false
0
0
As has already been mentioned, not all functions are invertible. In some cases imposing additional constraints helps: think about the inverse of sin(x). Once you are sure your function has a unique inverse, solve the equation f(x) = y. The solution gives you the inverse, y(x). In python, look for nonlinear solvers from scipy.optimize.
1
11
1
Is there any library available to have inverse of a function? To be more specific, given a function y=f(x) and domain, is there any library which can output x=f(y)? Sadly I cannot use matlab/mathematics in my application, looking for C/Python library..
Calculate inverse of a function--Library
1
0
0
36,620
15,200,952
2013-03-04T11:53:00.000
0
0
0
1
python,google-app-engine,app-engine-ndb,wtforms,google-cloud-endpoints
15,202,052
1
false
1
0
Not this is is always the best solution, but you could roll your own. Just pre-define a bunch of properties with reg-exs/mins and maxs etc. It seems like your properties are straight forward enough that it wouldn't be too difficult.
1
0
0
I wonder what the best approach is for validating NDB entity properties likes: a date must be in the future a grade (integer property) must be between 1 and 10 a reference to another entity must have certain property values (e.g. book.category.active must be True) I'm also using WTForms to validate submitted requests, but I want to enforce validations also on a lower level like the datastore entities itself. So basically what I'm looking for is to call a validate on a datastore entity to see if it's valid or not. In case it's valid I can put the entity to the datastore, but if it's not valid I want to retrieve the invalid properties including the applies validator that did not validate successfully. Another reason WTForms might not be sufficient is that I'm experiencing with the new Cloud Endpoints. In this model I'm receiving the actial entity and not a http request. How are other AppEngine users solving this?
AppEngine NDB property validations
0
0
0
744
15,202,503
2013-03-04T13:18:00.000
0
0
0
0
python,mysql,django
15,203,056
3
false
1
0
As others have noted, Python 3 support in Django 1.5 is "experimental" and, as such, not everything should be expected to work. That being said, if you absolutely need to get this working, you may be able to run the 2to3 tool on a source version of MySQL-python to translate it to Python 3 (and build against Python 3 headers if required).
1
1
0
Django needs MySQL-python package to manipulate MySQL, but MySQL-python doesn't support Python 3.3. I have tried MySQL-for-Python-3, but it doesn't work. Please help! Thanks a lot!
How can I use MySQL with Python 3.3 and Django 1.5?
0
1
0
713
15,202,913
2013-03-04T13:40:00.000
6
0
1
0
python,regex
15,202,938
2
true
0
0
use the start.*?end in the re. The question mark means "as few as possible".
1
2
0
I am working with python regular expression basics .I have a string startabcsdendsffstartsdfsdfendsstartdfsfend. How do i get the strings in between consecutive start and end without matching the entire string?
python regular expression repeating pattern matching entire string
1.2
0
0
3,140
15,207,938
2013-03-04T18:00:00.000
1
0
1
0
python,virtualenv,setuptools
33,958,217
1
false
0
0
Use a recent version of virtualenv and you will not see this error.
1
5
0
If you try to run virtualenv with the environmental variable PYTHONDONTWRITEBYTECODE=true set, it gives this error: The PYTHONDONTWRITEBYTECODE environment variable is not compatible with setuptools. Either use --distribute or unset PYTHONDONTWRITEBYTECODE. Why does setuptools require the ability to write bytecode? I don't particularly like having .pyc files around, so I like to prevent it from being written. (I'm not asking how to get around this; that's trivial: just add PYTHONDONTWRITEBYTECODE="" at the beginning of any command that requires the flag to be unset, or unset it globally)
Why does setuptools need to write bytecode?
0.197375
0
0
366
15,210,173
2013-03-04T20:08:00.000
2
0
1
0
python,csv
15,210,347
4
false
0
0
Not sure what you are trying to do with Multiple Sheets of CSV's. Let me elaborate my thinking on this. Maybe you want a folder with different CSV files in it. If you "can" use XML then probably you may want to have XML sheet in a big XML "Workbook". Haven't seen multiple sheets of csv yet.
2
12
0
Is there any way to create a CSV file with multiple sheets programmatically in Python?
Creating multiple CSV sheets in Python
0.099668
0
0
45,375
15,210,173
2013-03-04T20:08:00.000
12
0
1
0
python,csv
15,210,210
4
true
0
0
Multiple CSV files. One CSV file per sheet. A comma seperated value file is a plain text format. It is only going to be able to represent flat data, such as a table (or a 'Sheet') For storing multiple sheets, you should use separate CSV files. You can write each one separately and import/parse them individually into their destination.
2
12
0
Is there any way to create a CSV file with multiple sheets programmatically in Python?
Creating multiple CSV sheets in Python
1.2
0
0
45,375
15,210,454
2013-03-04T20:25:00.000
1
0
1
1
python,console
15,210,530
2
true
0
0
http://stackoverflow.com/questions/7054424/python-not-recognised-as-a-command Add python to your environment path. You should then be able to use it anywhere.
1
1
0
I've looked around for an answer to this, but i don't know how to phrase it in a way that google will understand. I'm trying to learn Python, and i've installed it on my machine. However, when i just type "python" in cmd.exe, the python app is not found/launched. I have to manually go to the directory in which python.exe is found in order to run my python commands. Is this normal? Online tutorials seem to indicate that I should be able to run the app from anywhere :s I'm on Win7, and trying to run Python from the Django stack by BitNami.
How to start app without navigating to its directory
1.2
0
0
113
15,210,470
2013-03-04T20:26:00.000
1
0
1
0
python,emacs
15,210,494
2
false
0
0
Usually CTRL-C works. Not sure about emacs-embedded interpreter. Alternatively, just provide the interpreter with whatever it's waiting for (in your example, an )).
1
6
0
If I mistype a command in the python intepreter, sometimes I just see .... For example if I type help(random.unif and press enter I cannot enter a new command. I have to exit emacs and start python and the interpreter again. Is there way to correct this?
How to cancel interpreter command in emacs python-mode
0.099668
0
0
1,411
15,212,377
2013-03-04T22:29:00.000
0
0
0
0
python,django,settings,web2py
17,322,358
1
false
1
0
Although they might not work the same under the hood, you can still put your application-wide global setting inside this file applications/yourapp/models/0_whatever_name.py Content in this file will be defined before (each) request reaches your app. Or you can simply append your app-wide global definitions into applications/yourapp/models/db.py By default it already contains lots of settings for this app.
1
1
0
I understand there is no such a thing like setting.py in Django for web2py . But is there a good place for these global setting for web2py ? I would like to put things like secret key, global constant and others.
web2py cross applications global setting good practice
0
0
0
202
15,214,572
2013-03-05T02:04:00.000
2
0
1
0
python,root
15,214,646
4
false
0
0
This is how I read it: Create a function that accepts a number as an argument (I'm assuming an integer, but that's not clear) find the nth root of that number, where n is one of 1,2,3,4 or 5. Return n and the root. if you can't find a suitable root, display an error.
2
0
0
I have a CompSci problem (optional), don't worry, you are not doing my homework :) I am having a rather impossible time understanding this question, as this is all I have to go on. It is in regards to a rather elementary understanding of python. I have to create a function that satisfies this requirement. I have no idea why there is a 6 in the problem or what it signifies. "Returns a pair of integers 'root' and 'pwr' s.t. 0 < pwr < 6 and root**pwr = user input. If no pairs of integers satisfy these conditions, the function will notify the user." Like I said, it's optional, so rather than just get the answer I am hoping for an explanation. Thanks you guys!
Supposedly Simple Python Homework
0.099668
0
0
408
15,214,572
2013-03-05T02:04:00.000
2
0
1
0
python,root
15,214,633
4
false
0
0
You're looking for a value, given a specific root, and a power between 0 and 6 exclusive, that is equivalent to a user's input. An example of that would be an input of 4 == 2**2, hence you'd probably output (2, 2). There doesn't appear to be any bounds on root.
2
0
0
I have a CompSci problem (optional), don't worry, you are not doing my homework :) I am having a rather impossible time understanding this question, as this is all I have to go on. It is in regards to a rather elementary understanding of python. I have to create a function that satisfies this requirement. I have no idea why there is a 6 in the problem or what it signifies. "Returns a pair of integers 'root' and 'pwr' s.t. 0 < pwr < 6 and root**pwr = user input. If no pairs of integers satisfy these conditions, the function will notify the user." Like I said, it's optional, so rather than just get the answer I am hoping for an explanation. Thanks you guys!
Supposedly Simple Python Homework
0.099668
0
0
408
15,216,240
2013-03-05T05:05:00.000
12
0
1
0
python
15,216,254
2
true
0
0
The second one is not a dictionary but a set. Both sets and dictionaries are unordered. The elements are not stored or displayed with any particular meaningful order.
2
3
0
So I am very new to python and I cant for the life of me figure out why these two statements evaluate differently, [3*x for x in range(1,11) if x > 5] [18, 21, 24, 27, 30] {3*x for x in range(1,11) if x > 5} set([24, 18, 27, 21, 30]) The top one makes perfect sense to me but why does the second print things in such a weird order? I know that hard brackets '[' are for lists and '{' for dictionaries.
Simple python list vs dictionary
1.2
0
0
332
15,216,240
2013-03-05T05:05:00.000
0
0
1
0
python
15,332,847
2
false
0
0
For dictionaries, you have to assig key, value pair, like {key:value} So the answer for your question goes like below, {3*x:3*x for x in range(1,11) if x > 5} Output would be like below, {18: 18, 21: 21, 24: 24, 27: 27, 30: 30}
2
3
0
So I am very new to python and I cant for the life of me figure out why these two statements evaluate differently, [3*x for x in range(1,11) if x > 5] [18, 21, 24, 27, 30] {3*x for x in range(1,11) if x > 5} set([24, 18, 27, 21, 30]) The top one makes perfect sense to me but why does the second print things in such a weird order? I know that hard brackets '[' are for lists and '{' for dictionaries.
Simple python list vs dictionary
0
0
0
332
15,218,412
2013-03-05T07:49:00.000
0
0
1
0
python-2.7,python-idle
15,219,429
2
false
0
0
Happened with me too once. Install Python. Then open IDLE and save an empty file with a .py extension. Then close IDLE. Go to the file that you have just saved. Then right click >> open with >> choose default program. Then choose python. There will be some more options like pythonw but you only choose python. After you are done, right click on the file and you will find "Edit with IDLE"So, that is it.
2
1
0
I had both Python 2.6 and 2.7 installed on my system and IDLE that I used (by right clicking on a Python file and selecting 'edit with IDLE') was from version 2.6. For some reason, I had to completely remove Python 2.6 form my system. Now, Python files don't show 'edit with IDLE' on right click, even though IDLE 2.7 is installed. I have also tried uninstalling Python 2.7 completely and re installing it. What could be wrong? Thanks
Python files don't recognize IDLE
0
0
0
1,116
15,218,412
2013-03-05T07:49:00.000
0
0
1
0
python-2.7,python-idle
32,930,377
2
false
0
0
The way to do it is to go right click on the file then choose look another app on PC and go C:\Python27\Lib\idlelib and choose the idle (batch file for windows)
2
1
0
I had both Python 2.6 and 2.7 installed on my system and IDLE that I used (by right clicking on a Python file and selecting 'edit with IDLE') was from version 2.6. For some reason, I had to completely remove Python 2.6 form my system. Now, Python files don't show 'edit with IDLE' on right click, even though IDLE 2.7 is installed. I have also tried uninstalling Python 2.7 completely and re installing it. What could be wrong? Thanks
Python files don't recognize IDLE
0
0
0
1,116
15,218,566
2013-03-05T08:00:00.000
5
0
0
0
python,django,exception-handling
15,218,682
1
false
1
0
yes, can handle all exceptions from any view. try Googling "django middleware exception", you'll find many solutions .
1
2
0
I know we can use try and except function to catch the error. But everyday I monitor the sentry, the system always get an exception in any views. As usual I put try and except to catch the errors in the views. My question is. Is it possible to catch all the errors from any views in just one function? Then the user will redirect to another page. Where is the best place to do this? I'm thinking about middleware but I don't have knowledge about it.
How to catch all the errors in all views?
0.761594
0
0
228
15,218,649
2013-03-05T08:05:00.000
0
0
0
0
python,web-applications,heroku
15,227,844
2
false
1
0
I would generally recommend your less than perfect approach, especially if you have a small number of files. Simplicity is always better than functionality.
1
1
0
I'm working on a Heroku app built in Python, and I can't find a recommended way to add a step to deployment for concatenating/processing/minifying JavaScript and CSS assets. For example, I might like to use tools like r.js or less. I've seen something called "collectstatic" that Heroku knows to run for Django apps, but my application is using web.py, not Django. One less-than-perfect approach would be to use these tools locally, on my development machine, to produce combined/compressed static assets. I could then check those compiled files into the git repository and push them to Heroku. Is there any support for this kind of step built in to Heroku? What is the best way of handling javascript/css files for Heroku web apps in Python?
build steps for javascript/css in heroku python app
0
0
0
342
15,221,155
2013-03-05T10:13:00.000
1
0
1
0
python,multithreading,instance
15,221,754
1
false
1
0
You can't (easily) "get an instance of a running program" from outside. You can certainly instrument your program so that it communicates its statistics somehow, eg via a socket, or as an even lower-tech solution you could get it to store the relevant data periodically in a file on disk or in a database, which your web app could read.
1
0
0
Suppose a python program is running. Say the object of an Class in that program can give you some stats. So if i have to develop a web UI to display the stats, how do i get the instance of that class which is running[as an separate desktop app] and display the stats in web, which I would be using web2py or django.
Get instance of an running Python program
0.197375
0
0
160
15,221,473
2013-03-05T10:29:00.000
8
0
1
0
python,upgrade,virtualenv,pip,package-managers
65,086,049
23
false
0
0
for windows, go to command prompt and use this command python -m pip install -–upgrade pip Dont forget to restart the editor,to avoid any error you can check the version of the pip by pip --version if you want to install any particular version of pip , for example version 18.1 then use this command, python -m pip install pip==18.1
3
771
0
I'm able to update pip-managed packages, but how do I update pip itself? According to pip --version, I currently have pip 1.1 installed in my virtualenv and I want to update to the latest version. What's the command for that? Do I need to use distribute or is there a native pip or virtualenv command? I've already tried pip update and pip update pip with no success.
How do I update/upgrade pip itself from inside my virtual environment?
1
0
0
1,701,097
15,221,473
2013-03-05T10:29:00.000
0
0
1
0
python,upgrade,virtualenv,pip,package-managers
72,138,923
23
false
0
0
While updating pip in virtual env use full path in python command Envirnments folder struture myenv\scripts\python h:\folderName\myenv\scripts\python -m pip install --upgrade pip
3
771
0
I'm able to update pip-managed packages, but how do I update pip itself? According to pip --version, I currently have pip 1.1 installed in my virtualenv and I want to update to the latest version. What's the command for that? Do I need to use distribute or is there a native pip or virtualenv command? I've already tried pip update and pip update pip with no success.
How do I update/upgrade pip itself from inside my virtual environment?
0
0
0
1,701,097
15,221,473
2013-03-05T10:29:00.000
0
0
1
0
python,upgrade,virtualenv,pip,package-managers
49,479,521
23
false
0
0
I had installed Python in C:\Python\Python36 so I went to the Windows command prompt and typed "cd C:\Python\Python36 to get to the right directory. Then entered the "python -m install --upgrade pip" all good!
3
771
0
I'm able to update pip-managed packages, but how do I update pip itself? According to pip --version, I currently have pip 1.1 installed in my virtualenv and I want to update to the latest version. What's the command for that? Do I need to use distribute or is there a native pip or virtualenv command? I've already tried pip update and pip update pip with no success.
How do I update/upgrade pip itself from inside my virtual environment?
0
0
0
1,701,097
15,224,804
2013-03-05T13:17:00.000
0
0
1
0
python,ide,visual-assist
15,224,832
6
false
0
0
You may use APTANA, Geany or ipython for your practice! I would prefer APTANA or GEANY Eclipse is also a good IDE for python too!
2
0
0
I use for C/C++ Visual studio 2012 with Visual Assist X plugin. Now I'm going to learn Python. I need good IDE for Python and my main requirement -very good intelli/autocomplete feature in IDE ( I don't like notepad or Python shell ) Can you recommended IDE for my requirement?
IDE for Python ( like Visual Studio with visual assist X )?
0
0
0
12,044
15,224,804
2013-03-05T13:17:00.000
0
0
1
0
python,ide,visual-assist
15,224,871
6
false
0
0
WingIDE is my preferred ide. It has pretty good intelligent fill.
2
0
0
I use for C/C++ Visual studio 2012 with Visual Assist X plugin. Now I'm going to learn Python. I need good IDE for Python and my main requirement -very good intelli/autocomplete feature in IDE ( I don't like notepad or Python shell ) Can you recommended IDE for my requirement?
IDE for Python ( like Visual Studio with visual assist X )?
0
0
0
12,044
15,225,320
2013-03-05T13:43:00.000
2
0
0
1
python,django,tornado,uwsgi
15,225,962
2
false
1
0
uWSGI+gevent is a solid combo, while there is currently no-way to run uWSGI with the tornado api (and as uWSGI dropped support in 1.9 for callback based approach, i think that we will never see that combo working). The problem you need to solve before starting working with gevent, is ensuring that all of your pieces are gevent friendly (redis and celery are ok, you need to check your database adapter). After that simply add --gevent to your uWSGI instance, where is the maximum number of concurrent requests per worker.
2
3
0
why? because I have a django project that capture data from user and consume many webservices displaying the results to the user in order to compare information, something like aggregators websites who search flights tickets via airlines webservices and show the result in real time in order to compare tickets. nowaday im doing this in a "waiting page", where celery hits webservices while jquery is asking every 5 seconds if all results are ready, so when ready redirect to the results page. what I want to do is not to use this "waiting page", I want to feed the results page in real time as the results are comming, and I want to make it following the best practices, I mean I dont want to jquery get the results each X seconds to feed the table. I think some coroutine-based python library can help me with this, but I want to learn more about your experience first and see some examples, I am confused because this part of the project was designed to run asynchronously, I mean, consuming webservices with celery-chords, but not designed for dispatching the information in real time through the app server. actual architecture: python 2.7, django 1.3, postgresql 9, celery 3 + redis, uwsgi, nginx, all hosted on aws. thank you in advance.
Can I use uwsgi + (tornado, gevent, etc) at the same time?
0.197375
0
0
1,970
15,225,320
2013-03-05T13:43:00.000
0
0
0
1
python,django,tornado,uwsgi
45,253,612
2
false
1
0
I don't know about uWSGI+gevent, but you can use tornado with uWSGI. Tornado basically gives you an inbuilt WSGI support in tornado.wsgi.WSGIContainer module to make it compactable with other WSGI servers like uWSGI and gunicorn.But it depends on your use and I think it's not a good idea to use an Asynchronous framework with a synchronous server(like uWSGI). Tornado has this warning for this. WSGI is a synchronous interface, while Tornado’s concurrency model is based on single-threaded asynchronous execution. This means that running a WSGI app with Tornado’s WSGIContainer is less scalable than running the same app in a multi-threaded WSGI server like gunicorn or uwsgi. Use WSGIContainer only when there are benefits to combining Tornado and WSGI in the same process that outweigh the reduced scalability.
2
3
0
why? because I have a django project that capture data from user and consume many webservices displaying the results to the user in order to compare information, something like aggregators websites who search flights tickets via airlines webservices and show the result in real time in order to compare tickets. nowaday im doing this in a "waiting page", where celery hits webservices while jquery is asking every 5 seconds if all results are ready, so when ready redirect to the results page. what I want to do is not to use this "waiting page", I want to feed the results page in real time as the results are comming, and I want to make it following the best practices, I mean I dont want to jquery get the results each X seconds to feed the table. I think some coroutine-based python library can help me with this, but I want to learn more about your experience first and see some examples, I am confused because this part of the project was designed to run asynchronously, I mean, consuming webservices with celery-chords, but not designed for dispatching the information in real time through the app server. actual architecture: python 2.7, django 1.3, postgresql 9, celery 3 + redis, uwsgi, nginx, all hosted on aws. thank you in advance.
Can I use uwsgi + (tornado, gevent, etc) at the same time?
0
0
0
1,970
15,226,643
2013-03-05T14:43:00.000
0
0
0
0
python,pyqt
15,227,528
3
false
1
0
Have a look at the nltk module---they have some utilities for looking at web pages and getting text. There's also BeautifulSoup, which is a bit more elaborate. I'm currently using both to scrape web pages for a learning algorithm---they're pretty widely used modules, so that means you can find lots of hints here :)
1
0
0
We have developed a web based application, with user login etc, and we developed a python application that have to get some data on this page. Is there any way to communicate python and system default browser ? Our main goal is to open a webpage, with system browser, and get the HTML source code from it ? We tried with python webbrowser, opened web page succesfully, but could not get source code, and tried with urllib2, in that case, i think we have to use system default browser's cookie etc, and i dont want to this, because of security.
python open web page and get source code
0
0
1
2,468
15,229,215
2013-03-05T16:35:00.000
3
0
1
0
python,boolean,pychecker
15,229,353
5
true
0
0
As a return value indicating absence of a result, None is almost always better. If you must use False, use not my_var. This assumes non - False return values are never "falsy" (bool() converts it into False - this is the case for empty strings, empty collections, and a few other things). If objects may be falsy but must be distinguished from False, then the comparison is necessary and you'll have to ignore the error (a minor variation, my_var is False would be slightly more idiomatic, but it's virtually the same). But that's not a nice situation to be in and you should avoid it for the fake of clarity. To repeat myself: If at all possible, use None and test for my_var is None.
2
2
0
I have a function that returns False if something isn't found, and returns a data structure with what I'm looking for otherwise. When I assign the value returned from this function to a variable my_var in a for loop, I do a if my_var == False: continue to carry on. pychecker doesn't like this and reports Comparisons with False are not necessary and may not work as expected. What's the python way for doing this?
What should replace comparisons with False in python?
1.2
0
0
1,586
15,229,215
2013-03-05T16:35:00.000
3
0
1
0
python,boolean,pychecker
15,229,406
5
false
0
0
Normally you would return None instead of False i.e. if an object doesn't match. And then check if my_var == None: as all not 0, not False and not None return True.
2
2
0
I have a function that returns False if something isn't found, and returns a data structure with what I'm looking for otherwise. When I assign the value returned from this function to a variable my_var in a for loop, I do a if my_var == False: continue to carry on. pychecker doesn't like this and reports Comparisons with False are not necessary and may not work as expected. What's the python way for doing this?
What should replace comparisons with False in python?
0.119427
0
0
1,586
15,230,638
2013-03-05T17:48:00.000
-3
0
0
0
python,django,django-south
15,230,769
2
true
1
0
There isn't a great way. This is why I avoid South dependencies at all costs. Don't use dependencies.
1
3
0
Let's say we have two apps in a project: app1 and app2. Both have South migrations and in this particular case, migration app1.0002_something depends on app2.0001_initial. Everything is nice and fine until you decide that app2 is obsolete and should be deleted (since its utility has been put into app3 and app4 a long time ago). And here lies the problem: after removing app2 from INSTALLED_APPS ./manage.py migrate returns south.exceptions.DependsOnUnmigratedApplication: Migration 'app1:0002_something' depends on unmigrated application 'app2'. In this case, I'd probably "reset" the migrations of app1 and go on coding, however, I don't see how I can avoid this situation in the future short of not using dependencies at all. So the questions are: How can I resolve this situation more gracefully than "resetting" migration history? How do I prevent this situation from happening and still be able to delete obsolete apps?
Deleting Django apps with South dependency
1.2
0
0
426
15,233,806
2013-03-05T20:47:00.000
2
0
1
0
python,twisted
15,235,815
1
true
0
0
You're misunderstanding how the operating system delivers events to Twisted. In most APIs, you have to actively pull events off a queue of some kind, you don't get alerted immediately when they happen. In situations where notifications do happen immediately (from a signal, or from another thread) Twisted enqueues them on the main thread instead. So, from your perspective as a programmer using Twisted, the answer to your question is simply "yes", but Stack Overflow makes me put more words in for it to be considered a valid answer :).
1
2
0
I just learned that Twisted uses a single thread to handle events. Hence you have to design non-blocking event handlers and ideally they will have to finish before another event is triggered. Requiring that blocking routines be implemented using deferred objects. Now, let's say you are handling an event, and another event is activated. A reasonable reaction to this scenario would be to queue the new event and wait until the running handler finishes. Is this what's happening inside the Twisted engine?
Multiple events activated in Twisted
1.2
0
0
70
15,233,928
2013-03-05T20:54:00.000
1
0
0
0
python,django
15,234,241
2
false
1
0
Any answer to this question is open for discussion. That said, views are just Python classes, so you could overwrite any method to customize things accordingly. It is also perfectly legit to create an extra method on your class to handle data processing.
2
5
0
I'm currently trying to get into "Class Based Views" with Django 1.5. From the design perspective i wonder where to put the logic to process data comming from a form in a simple FormView. I know that all form validation code comes into the method form_valid(). But where to put things which processes data of the form. I read that its somehow inappropriate to put too much logic into the form_valid() method. There are the get(), post(), get_context_data(), head(), etc. methods... which should I use in which case?
Design of CBVs in Django
0.099668
0
0
233
15,233,928
2013-03-05T20:54:00.000
1
0
0
0
python,django
15,238,942
2
true
1
0
Form validation, data cleaning, etc goes with the form class in the clean methods Processing of a valid form should go in an overridden form_valid method That's it! If your use-case is more complicated you can call out to other methods of your creation from form_valid...
2
5
0
I'm currently trying to get into "Class Based Views" with Django 1.5. From the design perspective i wonder where to put the logic to process data comming from a form in a simple FormView. I know that all form validation code comes into the method form_valid(). But where to put things which processes data of the form. I read that its somehow inappropriate to put too much logic into the form_valid() method. There are the get(), post(), get_context_data(), head(), etc. methods... which should I use in which case?
Design of CBVs in Django
1.2
0
0
233
15,235,085
2013-03-05T22:06:00.000
0
0
0
1
python,automation,task,scheduler
15,235,210
3
false
0
0
I would try it with the script not in your Users directory
1
0
0
I have written a python script and wanted to have it run at a set period everyday with the use of Task Scheduler. I have had no problems with Task Scheduler for running programs while logged off, before creating this task. If I select "Run only when user is logged on" my script runs as expected with the desired result and no error code (0x0). If I select "Run whether user is logged on or not" with "Run with highest privileges" and then leave it overnight or log off to test it, it does not do anything and has an error code of 0x1. I have the action to "Start a program" with the Details as follows: Program/script: C:\Python27\python2.7.exe Add arguments: "C:\Users\me\Desktop\test.py" I think it has to do with permissions to use python while logged off but I can't figure this one out. Wondering if anyone has suggestions or experience on this. This is on Windows 7 (fyi) Thanks, JP
Python script will not run in Task Scheduler for "Run whether use is logged on or not"
0
0
0
2,604
15,237,706
2013-03-06T02:07:00.000
0
0
0
0
python,django,amazon-s3
15,782,517
2
false
1
0
You can just create index.html inside /static-pages/12345/ folder and it will be served.
1
2
0
I'm planning to build a Django app to generate and later server static pages (probably stored on S3). When users visit a url like mysite.com/static-pages/12345 the static file in my S3 bucket named 12345.html should be served. That static file might be the static html page of a blog page my site has generated for the user, for example. This is different from including static resources like CSS/Javascript files on a page that is rendered as a Django template since I already know how to use Django templates and SQL databases - what's unfamiliar to me is that my "data" is now a file on S3 rather than an entry in a database AND that I don't actually need to use a template. How exactly can I retrieve the requested data (i.e. a static page) and return it to the user? I'd like to minimize performance penalties within reason, although of course it would be fastest if users directly requested their static pages from S3 (I don't want them to do this)". A few additional questions: I've read elsewhere about a django flatpages app which stores html pages in a database, but it seems like static html pages are best stored on a filesystem like S3, no? Is there a way to have the request come in to my Django application and have S3 serve the file directly while making it appear to have come from my application (i.e. the browser url still says mysite.com/static-pages/12345, but the page did not go through my Django server)? Thanks very much!
Serve Static Pages from S3 using Django
0
0
0
795
15,238,481
2013-03-06T03:32:00.000
0
0
1
0
python
15,239,080
2
true
0
0
If what you really mean by n is the length of the range list, there is no way to achieve this using a dictionary. For example, if the range is [(0,100000000000)], doing this in a dictionary would take exponentially long with respect to the number of bits in the range list. You can achieve your operations in nlogn, where n is length of the range list, if you chose the correct data representation and algorithm. This is in general exponentially faster than a runtime of O(n) with respect to the actual number of elements in the range. Here is a possible solution: Define a data structure consisting of range lists. The elements that fall inside a range in the list have been 'flipped' from their original, starting state. Define a routine that 'merges' a new set of flips (an incoming range list) with the existing one, and finds the disjoint set of flips. The routine should: Merge the data structure's ranges with the incoming range list. Find set of ranges with smallest first element, call it A. Find set of ranges which start before the last range in A ends, merge it with A. Sort the ranges in A according to first element. Split each range (a,b) in A into (a,b1) and (b1,b), for each (b1,?) in A. The ranges in A should now be non-overlapping. Delete all pairs of (a,b). (a,b) should now be unique in A. Concatenate all the ranges (a,b), (b,c) into (a,c) in A. Add A to the data structure. Go to step 2, starting with next smallest element not yet added.
1
0
0
I am trying to change a range of values in a dictionary in runtime of O(n). Where n is number of elements in the range that I need to change. for example if my dictionary has numbers for keys, and I am getting a list of range of keys list = [ (key1,key3), (key2,key3)] in this case if I start with d = {key1: odd , key2: even, key3: odd , key4: even} So I will have after the first range d = {key1: even , key2: odd, key3: even , key4: even} after the second range of keys d = {key1: even , key2: even, key3: odd , key4: even} can it be achieved in python?
change a range of items in a dictionary in order O(n)
1.2
0
0
112
15,250,538
2013-03-06T14:53:00.000
3
0
0
1
python,scons
15,252,510
3
false
0
0
Well, I guess it's possible in theory. The scons executable itself is just a python script and all it does is execute SCons.Script.main() after modifying the sys.path variable. But you would probably have to start digging deep into the source to really understand how to make it do things you want. A much cleaner solution is calling your script from the SConscript file, which is probably the intended usage and should prove much easier.
2
8
0
I'm new to scons and Python. I was wondering if there's a way to invoke scons from within a python script. My python script accepts from the user, a list of directories where the code to be compiled together is located (in addition to doing some other non-trivial things). It also generates a string which is to be used as a name of the executable created by scons. I want to pass this information from my python script to scons, and then invoke scons. Is there a simple way to do this? I can think of the following possibilities: use subprocess.call("scons"...) I'm not sure if scons accepts all the info I need to pass as command line arguments have the python script write into a file. Have the SConscript parse the file and get the information passed.
Invoking scons from a Python script
0.197375
0
0
2,664
15,250,538
2013-03-06T14:53:00.000
1
0
0
1
python,scons
15,271,954
3
false
0
0
Thanks for the answers. I ended up using this method: The python script writes a list of options into a text file, closes it, and invokes scons -f MySConscript_file using a subprocess call. The SConstruct reads values from the text file into a list, and uses them.
2
8
0
I'm new to scons and Python. I was wondering if there's a way to invoke scons from within a python script. My python script accepts from the user, a list of directories where the code to be compiled together is located (in addition to doing some other non-trivial things). It also generates a string which is to be used as a name of the executable created by scons. I want to pass this information from my python script to scons, and then invoke scons. Is there a simple way to do this? I can think of the following possibilities: use subprocess.call("scons"...) I'm not sure if scons accepts all the info I need to pass as command line arguments have the python script write into a file. Have the SConscript parse the file and get the information passed.
Invoking scons from a Python script
0.066568
0
0
2,664
15,252,040
2013-03-06T15:56:00.000
1
0
1
0
python,python-import,python-module,pythonpath
15,252,094
4
false
0
0
Python has a path variable just like the one you have inside your terminal. Python looks for modules in folders inside that path, or in the folder where your program is located.
1
70
0
Everywhere I see Python code importing modules using import sys or import mymodule How does the interpreter find the correct file if no directory or path is provided?
How does python find a module file if the import statement only contains the filename?
0.049958
0
0
58,389
15,252,734
2013-03-06T16:25:00.000
0
0
1
0
python,graph,dependencies,pip
15,273,802
2
true
0
0
Heres what i found during my search: Pip doesn't use a Dependency-graph at all internally. (As of version 1.3.X) So one solution is to do the following: You can install setuptools, if you havent allready. It brings a module named pkg_resources. This module has all the tools, to see all installed modules (not only the ones installed with pip) in your desired dists-directory. You can then read out the metadata (including requirements/dependencies) with methods that are as well included in pkg_resources.
1
1
0
I want to write a visualization of the Dependency-Graph of all python-packages installed with pip. My problem is that the code is poorly documented, and im unable to find where the Graph is stored in the source Code. I hope someone has enough knowledge about pip-sourcecode to help me out. Also im new to python and am not sure if i should just make my adjustments in the existing source-code, or write a module for it, although im leaning more towards the latter. // edit: I can get all installed modules via pip freeze, but that givbes me only one list without the dependencies. So i have to find a way to extract the dependencies from that list.
Utilizing the Dependency-Graph of pip
1.2
0
0
1,594
15,254,100
2013-03-06T17:31:00.000
1
0
0
0
python,flask
15,255,903
1
true
1
0
If you need to unit test the code separate from the View then you should defiantly separate it into another module or class. As there seems to be three parts to your business logic then I would say starting by splitting the view into three functions of a module seems a good place to start.
1
0
0
Please help me how to solve following task in "pythonic" way: There are several model classes, which are mapped to the DB with the help of SQLAlchemy. There is a Flask view, which handles the "POST" request. The business logic of this method contains complex logic which includes: Getting input parameters from input JSON Validation Creation of several different models and the saving to database. Is it a good idea to leave this logic in the "View"? Or it would be much better to separate this this logic into different modules or classes, for instance by introducing business logic class?
Flask: View, model and business logic segration
1.2
0
0
2,086
15,254,538
2013-03-06T17:55:00.000
14
0
0
1
python,tornado
15,265,556
4
true
1
0
Tornado designed to be stateless and don't have session support out of the box. Use secure cookies to store sensitive information like user_id. Use standard cookies to store not critical information. For storing large objects - use standard scheme - MySQL + memcache.
3
14
0
So, in order to avoid the "no one best answer" problem, I'm going to ask, not for the best way, but the standard or most common way to handle sessions when using the Tornado framework. That is, if we're not using 3rd party authentication (OAuth, etc.), but rather we have want to have our own Users table with secure cookies in the browser but most of the session info stored on the server, what is the most common way of doing this? I have seen some people using Redis, some people using their normal database (MySQL or Postgres or whatever), some people using memcached. The application I'm working on won't have millions of users at a time, or probably even thousands. It will need to eventually get some moderately complex authorization scheme, though. What I'm looking for is to make sure we don't do something "weird" that goes down a different path than the general Tornado community, since authentication and authorization, while it is something we need, isn't something that is at the core of our product and so isn't where we should be differentiating ourselves. So, we're looking for what most people (who use Tornado) are doing in this respect, hence I think it's a question with (in theory) an objectively true answer. The ideal answer would point to example code, of course.
standard way to handle user session in tornado
1.2
1
0
14,722
15,254,538
2013-03-06T17:55:00.000
17
0
0
1
python,tornado
16,320,593
4
false
1
0
Here's how it seems other micro frameworks handle sessions (CherryPy, Flask for example): Create a table holding session_id and whatever other fields you'll want to track on a per session basis. Some frameworks will allow you to just store this info in a file on a per user basis, or will just store things directly in memory. If your application is small enough, you may consider those options as well, but a database should be simpler to implement on your own. When a request is received (RequestHandler initialize() function I think?) and there is no session_id cookie, set a secure session-id using a random generator. I don't have much experience with Tornado, but it looks like setting a secure cookie should be useful for this. Store that session_id and associated info in your session table. Note that EVERY user will have a session, even those not logged in. When a user logs in, you'll want to attach their status as logged in (and their username/user_id, etc) to their session. In your RequestHandler initialize function, if there is a session_id cookie, read in what ever session info you need from the DB and perhaps create your own Session object to populate and store as a member variable of that request handler. Keep in mind sessions should expire after a certain amount of inactivity, so you'll want to check for that as well. If you want a "remember me" type log in situation, you'll have to use a secure cookie to signal that (read up on this at OWASP to make sure it's as secure as possible, thought again it looks like Tornado's secure_cookie might help with that), and upon receiving a timed out session you can re-authenticate a new user by creating a new session and transferring whatever associated info into it from the old one.
3
14
0
So, in order to avoid the "no one best answer" problem, I'm going to ask, not for the best way, but the standard or most common way to handle sessions when using the Tornado framework. That is, if we're not using 3rd party authentication (OAuth, etc.), but rather we have want to have our own Users table with secure cookies in the browser but most of the session info stored on the server, what is the most common way of doing this? I have seen some people using Redis, some people using their normal database (MySQL or Postgres or whatever), some people using memcached. The application I'm working on won't have millions of users at a time, or probably even thousands. It will need to eventually get some moderately complex authorization scheme, though. What I'm looking for is to make sure we don't do something "weird" that goes down a different path than the general Tornado community, since authentication and authorization, while it is something we need, isn't something that is at the core of our product and so isn't where we should be differentiating ourselves. So, we're looking for what most people (who use Tornado) are doing in this respect, hence I think it's a question with (in theory) an objectively true answer. The ideal answer would point to example code, of course.
standard way to handle user session in tornado
1
1
0
14,722
15,254,538
2013-03-06T17:55:00.000
4
0
0
1
python,tornado
16,346,968
4
false
1
0
The key issue with sessions is not where to store them, is to how to expire them intelligently. Regardless of where sessions are stored, as long as the number of stored sessions is reasonable (i.e. only active sessions plus some surplus are stored), all this data is going to fit in RAM and be served fast. If there is a lot of old junk you may expect unpredictable delays (the need to hit the disk to load the session).
3
14
0
So, in order to avoid the "no one best answer" problem, I'm going to ask, not for the best way, but the standard or most common way to handle sessions when using the Tornado framework. That is, if we're not using 3rd party authentication (OAuth, etc.), but rather we have want to have our own Users table with secure cookies in the browser but most of the session info stored on the server, what is the most common way of doing this? I have seen some people using Redis, some people using their normal database (MySQL or Postgres or whatever), some people using memcached. The application I'm working on won't have millions of users at a time, or probably even thousands. It will need to eventually get some moderately complex authorization scheme, though. What I'm looking for is to make sure we don't do something "weird" that goes down a different path than the general Tornado community, since authentication and authorization, while it is something we need, isn't something that is at the core of our product and so isn't where we should be differentiating ourselves. So, we're looking for what most people (who use Tornado) are doing in this respect, hence I think it's a question with (in theory) an objectively true answer. The ideal answer would point to example code, of course.
standard way to handle user session in tornado
0.197375
1
0
14,722
15,255,989
2013-03-06T19:14:00.000
1
0
0
1
c++,python,swig
15,264,849
2
false
0
0
I finally figured out! I executed the command ulimit -c unlimited After this i see a core dump, now i can analyse it via gdb /usr/bin/python2.3 core.31685
1
1
0
I have to run some unit tests which are written in Python. We have the code to test in c++, so I compiled it into a shared object and using swig providing an interface for the python scripts to call into the necessary api's to test. Now when i run one of the python scripts (it is obviously accessing the c++ codebase which i intend to test), i am getting a "glibc detected free(): invalid pointer". Now I do understand that there is some memory issue, either a double free or I am freeing an inaccessible memory. Now what i am requesting from you experts: 1] I am not getting any backtrace(no line number even), is there anyway to know where the issue is happening? I am not getting any info other than the script stopping abruptly at some point and printing something like this *** glibc detected * free(): invalid pointer: 0x099e9b28 *** Can i get a backtrace somehow? By setting some flag may be? 2] I ran valgrind: "valgrind --leak-check=yes ./myscript.py" I did not get something much, some lines from it: glibc detected free(): invalid pointer: 0x099e9b28 ==25728== ==25728== Conditional jump or move depends on uninitialised value(s) ==25728== at 0x625AEA: PyObject_Free (in /usr/lib/libpython2.3.so.1.0) ==25728== by 0x614C7F: (within /usr/lib/libpython2.3.so.1.0) ==25728== by 0x61EA53: (within /usr/lib/libpython2.3.so.1.0) I am not getting anything related to my code basically. So is there something else i should do with valgrind. 3] I tried printfs, its taking me to nothing actually. 4] I tried gdb: prompt>gdb python gdb> set args myscript.py gdb> run This runs the script, I could not set any breakpoints, it runs and prints the error. No absolute help. Is there something else i should do with GDB? Any way to set breakpoints? Thanks a lot for any kind of pointer you guys can give me.
glibc detected *** free(): invalid pointer: Python c++ and Swig
0.099668
0
0
2,165
15,256,240
2013-03-06T19:27:00.000
0
0
0
0
javascript,python,html
15,256,392
1
true
1
0
The simplest way is to create a page with an iframe, call it result. Then create a simple <form> and give the form tag an attribute target="result". Include a textarea in your form. Your students' code is transfered to the webserver via a simple form submit. Then when your server produces an HTML response it is rendered in the iframe. No javascript is needed. KISS!
1
0
0
Hi all this is my first post as I have exhausted google and am asking for a little bit of help. I'm a school teacher and I'm creating an ELearning website for my school, at present I'm attempting to create a code window where my students can input some python syntax and onlick the code is converted and shown in the adjacent window. Very similar to what is used in W3schools for its examples and various elearning websites. Does anybody have any knowledge as to where I should start or have any links about creating this? I would probably go along the lines of when the 'submit code' button is pressed, a javascript object is created of the user input code, then rendered into the adjacent result box using some sort of ajax. Thanks all for your kind, regards Andrew
Creating a frame that can read Python and convert it to HTML
1.2
0
0
109
15,256,458
2013-03-06T19:38:00.000
1
0
1
0
python,instructions
15,256,488
1
true
0
0
I doubt it. Usually, the only robust way to do this is to run the untrusted code in a separate process, properly sandboxed. Consider what happens if the untrusted code acquires some critical resource (e.g. a lock), and then gets killed because it's taking too long. The entire process will deadlock if anyone will try to acquire that same lock.
1
2
0
Is it possible to have some function that increments a counter run upon each instruction within a function, and does some behavior if a number is reached? To explain, I want to be able to raise an exception if a function ends up taking up past a certain number of bytecode instructions in the virtual machine. So, if someone creates a list comprehension that will make an infinite loop, or creates an infinite while loop, it will force a break out early. Can this be done in Python?
Python instruction counting
1.2
0
0
1,394
15,258,506
2013-03-06T21:32:00.000
-2
0
1
0
python,windows,symlink,pywin32
51,768,106
5
false
0
0
Just using if file[-4:len(file)] != ".lnk": works for me
1
12
0
On Windows 7 with Python 2.7 how can I detect if a path is a symbolic link? This does not work os.path.islink(), it says it returns false if false or not supported and the path I'm providing is definitely a symbolic link so I'm assuming it's not supported on windows? What can I do?
os.path.islink on windows with python
-0.07983
0
0
5,931
15,258,779
2013-03-06T21:50:00.000
2
0
1
0
python,c,parsing,equivalence
15,260,213
2
false
0
0
To do this, you need control flow anlaysis to determine if the two conditions have the same control dependence (otherwise they don't execute in the same data context), full data flow analysis including points-to analysis of the C code, a side-effect analysis of functions, the ability to backslice from the root of the condition to the leaves of the expression across function calls, and then a boolean equivalence matcher that accounts for C semantics (e.g. short-circuiting, overflows, ...) This is far beyond what you get from a C parser.
1
9
0
I have 'if statements' from two different sources, which try to implement the same condition possibly in a different way. The 'if statements' are C. If at all possible I need a python script that can decide whether pairs of conditions are equivalent or not. A basic example: source1: ((op1 != v1) || ((op2 != v2) || (op3 != v3))) source2: ((op2 != v2) || (op1 != v1) || (op3 != v3)) Of course any operator is allowed, function calls and of course parentheses. Any ideas are welcome. Edit 1: The function calls have no side effects.
Check if two "simple" 'if statements' in C are equivalent
0.197375
0
0
387
15,259,499
2013-03-06T22:37:00.000
0
0
0
1
python,jython,apache-pig
20,953,873
1
false
1
0
From my short experience in Pig there are two ways of doing this: you can either place the jar in your Pig's lib folder, somewhere about /usr/share/pig/lib/, or register the jar using its specific location from grunt (Pig shell), using: REGISTER /path/to/your/jar/jython.jar; Once available, register your UDF from grunt using: REGISTER '/path/to/your/udf/udf.py' USING jython as py_udf; And you can use it like this: py_udf.my_method(*) my_method being the name of the python method you created.
1
2
0
I have jython jar and Pig installed on the server. Have Pig jars as well. Can someone help me out with the proper steps to bundle them so that I can use my Python UDFs ? Thanks
How to make Jython work with PIG?
0
0
0
432
15,259,639
2013-03-06T22:45:00.000
4
0
1
0
python,module,package,python-import
15,274,453
1
true
0
0
Yes, just import it everywhere it's needed. Don't get too clever with writing functions that import everything for you or metamodules that import things and from which you import *; all of that only serves to make your code hard to read and is just another place for bugs to happen.
1
2
0
I'm trying to write my first Python package, and almost all my modules will need to use NumPy. Should I write import numpy in every single module or is there some place in the package I can just import it once so every module can use it? What's the best way to do this?
create Python package and import modules
1.2
0
0
248
15,260,422
2013-03-06T23:45:00.000
0
1
0
1
python,testing,nose,pytest
25,073,350
1
false
0
0
I am not sure if this would help. But if you know ahead of time how you want to divide up your tests, instead of having pytest distribute your tests, you could use your continuous integration server to call a different run of pytest for each different machine. Using -k or -m to select a subset of tests, or simply specifying different test dir paths, you could control which tests are run together.
1
3
0
I have several thousand tests that I want to run in parallel. The tests are all compiled binaries that give a return code of 0 or non-zero (on failure). Some unknown subsets of them try to use the same resources (files, ports, etc). Each test assumes that it is running independently and just reports a failure if a resources isn't available. I'm using Python to launch each test using the subprocess module, and that works great serially. I looked into Nose for parallelizing, but I need to autogenerate the tests (to wrap each of the 1000+ binaries into Python class that uses subprocess) and Nose's multiprocessing module doesn't support parallelizing autogenerated tests. I ultimately settled on PyTest because it can run autogenerated tests on remote hosts over SSH with the xdist plugin. However, as far as I can tell, it doesn't look like xdist supports any kind of control of how the tests get distributed. I want to give it a pool of N machines, and have one test run per machine. Is what I want possible with PyTest/xdist? If not, is there a tool out there that can do what I'm looking for?
Controlling the distribution of tests with py.test xdist
0
0
0
1,185
15,260,888
2013-03-07T00:27:00.000
0
0
1
1
python,filenames,stdin
15,261,083
4
false
0
0
I don't think it's possible. As far as your python script is concerned it's writing to stdout. The fact that you are capturing what is written to stdout and writing it to file in your shell has nothing to do with the python script.
1
8
0
I'm trying to get the filename thats given in the command line. For example: python3 ritwc.py < DarkAndStormyNight.txt I'm trying to get DarkAndStormyNight.txt When I try fileinput.filename() I get back same with sys.stdin. Is this possible? I'm not looking for sys.argv[0] which returns the current script name. Thanks!
Python stdin filename
0
0
0
7,109
15,260,971
2013-03-07T00:35:00.000
1
0
1
0
python,numpy,import,python-3.3,pyscripter
15,956,833
3
false
0
0
Depends on which Python engine you are using in pyscripter. The IDE offers a connect to its own internal installation of python and a remote installation (typically the version you had in place before installing the ide.You need to ensure pyscripter is connected to the remote engine.
3
0
0
I'm working with python 3.3 (x64), and pyscripter 2.5.3 (x64), numpy 1.7 for python 3.3 (x64). When I import numpy in a script, I don't have all the functions of numpy available, only few of them (not a lot, and not array )? As if it doesn't manage to import all the file from numpy If I use IDLE it works fine, same with notepad++.
importing numpy works with interpreter but not fully with pyscripter in python
0.066568
0
0
961
15,260,971
2013-03-07T00:35:00.000
1
0
1
0
python,numpy,import,python-3.3,pyscripter
22,145,533
3
false
0
0
I also had the same issue check the path of the python in PyScripter. It is in the Tools -> python path check if it is referring to the correct path of python if it doesn't correct it and hopefully it will work
3
0
0
I'm working with python 3.3 (x64), and pyscripter 2.5.3 (x64), numpy 1.7 for python 3.3 (x64). When I import numpy in a script, I don't have all the functions of numpy available, only few of them (not a lot, and not array )? As if it doesn't manage to import all the file from numpy If I use IDLE it works fine, same with notepad++.
importing numpy works with interpreter but not fully with pyscripter in python
0.066568
0
0
961
15,260,971
2013-03-07T00:35:00.000
0
0
1
0
python,numpy,import,python-3.3,pyscripter
15,414,492
3
false
0
0
The problem is related with pyscipter. Try to import numpy using Python Shell
3
0
0
I'm working with python 3.3 (x64), and pyscripter 2.5.3 (x64), numpy 1.7 for python 3.3 (x64). When I import numpy in a script, I don't have all the functions of numpy available, only few of them (not a lot, and not array )? As if it doesn't manage to import all the file from numpy If I use IDLE it works fine, same with notepad++.
importing numpy works with interpreter but not fully with pyscripter in python
0
0
0
961
15,261,000
2013-03-07T00:38:00.000
1
0
0
0
python,url,data-structures,pyramid
15,261,264
2
false
1
0
I am new to Python and programming but here a few issues I can see with 'random string' idea: You will most probably end up generating same string over and over if you are using shorter strings. On the other side if you are using longer strings, the changes of getting the same string is less. However you will want to watch out for duplicates on either case. Therefore my suggestion is to make some estimations of how many urls you will need, and use an optimal string length for it. Easiest way is to keep these urls in a list, and use a simple if check before registering new ones: if new_url in url_list: generate_new_url() else: url_list.append(new_url) However it also sounds like you will want to employ a database to permanently store your urls. In most sql based databases you can setup your url column to be 'unique'; therefore database stops you from having dublicate urls. I am not sure but with the database you can probably do this: try: #insert value to database except: generate_new_url()
1
4
0
In my python/pyramid app, I let users generate html pages which are stored in an amazon s3 bucket. I want each page to have a separate path like www.domain.com/2cxj4kl. I have figured out how to generate the random string to put in the url, but I am more concerned with duplicates. how can I check each of these strings against a list of existing strings so that nothing is overwritten? Can I just put each string in a dictionary or array and check the ever growing array/dict each time a new one is created? Are there issues with continuing to grow such an object, and will it permanently exist in the app memory somehow? How can I do this?
How can I generate a random url of a certain length every time a page is created?
0.099668
0
0
7,292
15,263,196
2013-03-07T04:39:00.000
2
0
0
0
python,kettle
15,274,794
1
true
0
0
It doesnt support it directly from what I've seen. However there is a mongodb input step. And a lot of work has been done on it recently ( and still ongoing. So given there is a mongodb input step, if you're using an ETL tool already then why would you want to make it execute a python script to do the job??
1
3
0
I have a problem in kettle connecting python. In kettle, I only find the js script module. Does kettle support python directly? I mean, can I call a python script in kettle without using js or others? By the way, I want to move data from Oracle to Mongo regularly. I choose to use python to implement the transformation. So without external files, does it have some easy methods to keep the synchronization between a relational db and a no-rdb? Thanks a lot.
how to call python script in kettle
1.2
1
0
6,043
15,263,854
2013-03-07T05:33:00.000
0
1
0
1
java,python,jakarta-ee
15,318,731
1
true
1
0
So, I discovered that the issue was with the arguments that I was passing in Java to run the python program. The first argument was - python 2.6 but it should have rather been just python not some version number because there was compatibility issue with MySQLdB and python. I finally decided to use MySQL Python connector instead of MySQLdB in python code. It worked like charm and the problems got solved !
1
3
0
I am calling a Python script from my Java code. This is the code : import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class JavaRunCommand { public static void main(String args[]) throws IOException { // set up the command and parameter String pythonScriptPath = "my-path"; String[] cmd = new String[2]; cmd[0] = "python2.6"; cmd[1] = pythonScriptPath; // create runtime to execute external command Runtime rt = Runtime.getRuntime(); Process pr = rt.exec(cmd); // retrieve output from python script BufferedReader bfr = new BufferedReader(new InputStreamReader( pr.getInputStream())); String line = ""; while ((line = bfr.readLine()) != null) { // display each output line form python script System.out.println(line); } } } python.py which works import os from stat import * c = 5 print c python.py which does not works import MySQLdb import os from stat import * c = 5 print c # some database code down So, I am at a critical stage where I have a deadline for my startup and I have to show my MVP project to the client and I was thinking of calling Python script like this. It works when I am printing anything without dB connection and MySQLdb library. But when I include them, it does not run the python script. Whats wrong here. Isnt it suppose to run the process handling all the inputs. I have MySQLdb installed and the script runs without the java code. I know this is not the best way to solve the issue. But to show something to the client I need this thing working. Any suggestions ?
Calling Python script from JAVA MySQLdb imports
1.2
0
0
534
15,265,319
2013-03-07T07:21:00.000
3
0
0
1
python,heroku,celery,amqp
15,734,662
5
false
1
0
I think there are issues with Celery as a background task on Heroku. We tried to create such tasks and they take all memory after running for about 20 minutes, even with DEBUG=False on Redis or RabbitMQ. Worse still, the memory is NEVER released: every time we have to restart the worker. The same code runs flawlessly on bare Linux or on Mac with Foreman. It happens with very simple tasks, like reading a text file in a loop, writing to a Django model.
1
13
0
I was finally getting to the point where I had some free time and wanted to add Celery to my Python/Flask project on Heroku. However, almost all mentions of Celery from the Heroku docs are gone. There used to be article with a tutotial in the "Getting started with Django", but it's gone. Will "just doing it" myself work? What's a good AMQP addon to use as backend on Heroku?
Does Heroku no longer support Celery?
0.119427
0
0
6,436
15,268,997
2013-03-07T10:41:00.000
3
0
0
0
python
15,269,253
1
true
0
0
Depending on your OS, the maximum value for request_queue_size will be 128 (that's the default maximum size on Linux and Mac OS X, at least). Higher values won't give an error but will just silently be limited. Higher values won't necessarily be a problem I think, although I would seriously consider using some form of threading (or, if appropriate, an asynchronous solution using gevent or something similar). The SocketServer module provides mixins for creating threaded or forking socket servers.
1
4
0
I'm going to run a small server inheriting from Python.SocketServer.TCPServer. In case the code is too slow, I could make it threaded or just expand the queue size, and it will take a bit longer to run. Are there any dangers in setting the request_queue_size to a large value (say a few thousands)? The only very important thing in my programme is that I don't lose any data.
Is it dangerous to have a very long request_queue_size in Python.SocketServer.TCPServer?
1.2
0
1
995
15,269,513
2013-03-07T11:05:00.000
0
1
0
0
python,matlab,simulink
15,504,906
2
false
0
0
You could also just run a MATLAB script that does a find_system on model filenames passed in and spits out the names of the blocks, thus avoiding any compatibility issues.
1
1
0
I want to search inside a simulink model for a particular object and point out it's directory.(Model path).
How can i access simulink by python?
0
0
0
575
15,271,870
2013-03-07T12:58:00.000
0
0
0
1
python,gtk
15,276,223
1
false
0
1
If your program has a Gtk UI then the program is supposed to be driven by the GTK main loop. You may be able to run a gtk main loop in a secondary thread, but that it not really a supported configuration and you may run into many more problems
1
0
0
I'm creating a program in python, and use GTK for part of it. Whenever GTK opens, it causes the whole program to stop responding, and not move on to the next process. Ideally, i would like it if the gtk window opened independently to the rest of the program, since the GTK window is just to display information, and the functionality is text based Is there any way to continue executing the python program, after the GTK window opened. I can't find anything in the pygtk manuals Any help would be great, thansks
gtk allow background processes
0
0
0
159
15,279,793
2013-03-07T19:15:00.000
0
0
1
1
python,windows,python-2.7
15,279,856
3
false
0
0
There is not "shebang" notation on Windows. You'll need to change the file association for .py files to use your 2.7.2 installation ("Open With", "Use application as default").
1
8
0
What line of text should I place at the top of a script.py to invoke the specific version of Python that I need to use? I have two versions of Python on Windows XP, 2.6.5 and 2.7.2. They each have their own special modules and were installed by separate applications. My scripts are placed on the desktop so that I can double-click and run them conveniently. The problem is that all my scripts invoke 2.6.5, which is fine for the scripts that use the modules installed with 2.6.5, but my scripts intended for 2.7.2 don't run. They invoke the Python 2.6.5 without the modules I need to import. I've tried typing various headers without and without the #! to invoke 2.7.2 when I need to, but either my syntax is wrong or it just isn't possible to specify under Windows. Could anyone tell me the precise syntax of the line I need to add to my script. The python.exe for 2.7.2 is stored under C:\OSGeo4W\bin Thanks for letting me know what line to place at the top of a script.py to invoke the exact version of Python I need to use.
How to invoke a specific Python version WITHIN a script.py -- Windows
0
0
0
7,048
15,282,318
2013-03-07T21:41:00.000
0
0
0
0
python,django,python-2.7
15,282,357
4
false
1
0
The created project should have a static folder. Put all resources (images, ...) in there. Then, in your HTML template, you can reference STATIC_ROOT and add the resource path (relative to the static folder)
2
1
0
I've looked through countless answers and questions trying to find a single definitive guide or way to do this, but it seems that everyone has a different way. Can someone please just explain to me how to serve static files in templates? Assuming I've just created a brand new project with Django 1.4, what all do I need to do to be able to render images? Where should I put the media and static folders?
Django Static Setup
0
0
0
528
15,282,318
2013-03-07T21:41:00.000
2
0
0
0
python,django,python-2.7
15,283,333
4
true
1
0
Put your static files into <app>/static or add an absolute path to STATICFILES_DIRS Configure your web server (you should not serve static files with Django) to serve files in STATIC_ROOT Point STATIC_URL to the base URL the web server serves Run ./manage.py collectstatic Be sure to use RequestContext in your render calls and {{ STATIC_URL }} to prefix paths Coffee and pat yourself on the back A little bit more about running a web server in front of Django. Django is practically an application server. It has not been designed to be any good in serving static files. That is why it actively refuses to do that when DEBUG=False. Also, the Django development server should not be used for production. This means that there should be something in front of Django at all times. It may be a WSGI server such as gunicorn or a 'real' web server such as nginx or Apache. If you are running a reverse proxy (such as nginx or Apache) you can bind /static to a path in the filesystem and the rest of the traffic to pass through to Django. That means your STATIC_URL can be a relative path. Otherwise you will need to use an absolute URL.
2
1
0
I've looked through countless answers and questions trying to find a single definitive guide or way to do this, but it seems that everyone has a different way. Can someone please just explain to me how to serve static files in templates? Assuming I've just created a brand new project with Django 1.4, what all do I need to do to be able to render images? Where should I put the media and static folders?
Django Static Setup
1.2
0
0
528
15,282,336
2013-03-07T21:42:00.000
0
0
0
0
python,nlp,nltk,sentiment-analysis,rapidminer
15,319,789
1
false
0
0
Well, I think that rapidminer is very interesting and can handle this task. It contains several operators dealing with text mining. Also, it allows the creation of new operators with high fluency.
1
2
1
I'm doing the sentiment analysis for the Arabic language , I want to creat my own corpus , to do that , I collect 300 status from facebook and I classify them into positive and negative , now I want to do the tokenization of these status , in order to obain a list of words , and hen generate unigrams and bigrams, trigrams and use the cross fold validation , I'm using for the moment the nltk python, is this software able to do this task fr the arabic language or the rapis Minner will be better to work with , what do you think and I'm wondering how to generate the bigrams, trigrams and use the cross fold validation , is there any idea ??
creating arabic corpus
0
0
0
1,057
15,282,925
2013-03-07T22:21:00.000
0
1
0
0
python,audio,raspberry-pi
15,306,454
1
true
0
0
Turns out it was file path naming. If I have the command line test to the root directory it doesn't work but if I "cd Desktop/containingFolder" then the sounds play. I'll play with how I have the files set up in the python script so it will work. Updating the path names fixed the issue. I just needed them to be full paths instead of relative ones.
1
2
0
I'm working on a Raspberry Pi project and I have a python script that accepts some serial input and plays sounds depending on the input. I have the script set up and it works just fine when I run it from within the GUI (i.e. startx). If I log out of the GUI and try to run the script from the command line the script executes just fine but my sounds don't play. I just get a momentary static click. I can tell the script is running because I have it printing debug code and the print's work just fine. Is there a way to get the sounds to work from the command line? I want this script to execute when the Raspberry Pi is turned on without user input which I believe means it will be running from the command line. If there is some reason the sounds simply won't play until the GUI starts up how would I set it up to load the GUI and then execute the script on startup without any user input? This will be embedded in a prop and will play sounds when some buttons (connected through arduino i.e. serial input) are pressed. So I need a solution that will have it from power on automatically run the script and be able to play the sounds with no keyboard, mouse, or monitor attached.
pygame.mixer sound not playing when script run from command line
1.2
0
0
1,725
15,283,483
2013-03-07T22:59:00.000
1
1
0
1
python,bash,shell
15,283,656
2
false
0
0
chmod +x cmd.py then they can type ./cmd.py they can also use it piped. I would add that unix users would probably already know how to make a file executable and run it, so all you'd have to do is make the file available to them. Do make sure they know what version(s) of python they need to run your script.
1
5
0
I have written a very simple command line utility for myself. The setup consists of: A single .py file containing the application/source. A single executable (chmod +x) shell script which runs the python script. A line in my .bash_profile which aliases my command like so: alias cmd='. shellscript' (So it runs in the same terminal context.) So effectively I can type cmd to run it, and everything works great. My question is, how can I distribute this to others? Obviously I could just write out these instructions with my code and be done with it, but is there a faster way? I've occasionally seen those one-liners that you paste into your console to install something. How would I do that? I seem to recall them involving curl and piping to sh but I can't remember.
How to distribute my Python/shell script?
0.099668
0
0
894
15,284,154
2013-03-07T23:48:00.000
1
0
0
1
python,nginx,uwsgi,bottle
15,287,095
2
false
0
0
If you are not in a hurry i suggest you to try uWSGI 1.9 (it is still in development but the first stable release will be in 10 days) and use offload-threads = n (set it to the number of cpus). In that way when you send a file from your app it will be asynced (and non blocking) served by a different thread, suddenly freeing your worker. Offloading is available in 1.4 too but it is not automatic for apps as in 1.9
1
5
0
I want to make bottle python web service to serve binary files like pdf, picture and exe with authentication. Is it possible to serve all this files using bottle? I have hard time finding a tutorial for that. How about the performance? Does bottle python handle hundreds of thousands downloads simultaneously? I am planning to use it with nginx uwsgi.
How bottle return binary files
0.099668
0
0
5,164
15,284,381
2013-03-08T00:08:00.000
0
0
1
1
python
56,398,790
3
false
0
0
You have few options In your bash ~/.bash_profile add alias python='python3' Instead of using python command use python3 instead. Install python3 via homebrew
1
2
0
Terminal is still showing Python 2.7.2 after an install of 3.3.0 I'm new to python- just want to get a good development environment working on Mac 10.8.
Installed Python from Package, Terminal didn't update?
0
0
0
2,274
15,285,564
2013-03-08T02:15:00.000
0
0
0
1
python,pip,hyde
15,325,334
1
false
0
0
I need to have /usr/local/share/python in my PATH.
1
0
0
I installed Hyde with pip. I can see hyde in /usr/local/share/python. But when I am running hyde from command line, I am getting "Bash - Command not found error". I am on Mac OSX (ML) and python 2.7.3 Please help.
Hyde static page site generator - issue with running hyde command from command line
0
0
0
203
15,286,169
2013-03-08T03:23:00.000
-1
0
1
0
python,rrd,ganglia
15,286,736
2
false
0
0
There won't be an inbuilt library module for it.
1
4
0
Is there any python module available for converting the .rrd file to json format ?
Convert .rrd file to json in python
-0.099668
0
0
3,061
15,291,294
2013-03-08T10:01:00.000
1
0
0
1
php,python,performance,logging
15,291,684
1
false
1
0
One possible option what I can think of is a separate logging process. So that your web.py can be shielded for performance issue. This is classical way of handling logging module. You can use IPC or any other bus communication infrastructure. With this you will be able to address two issues - Logging will not be a huge bottle neck for high capacity call flows. A separate module can ensure/provide switch off/on facility. As such there would not be any huge/significant process memory usage. However, you should bear in mind below points - You need be sure that logging is restricted to just logging. It must not be a data store for business processing. Else you may have many synchronization problem in your business logic. The logging process (here I mean actual Unix process) will become critical and slightly complex (i.e you may have to handle a form of IPC). HTH!
1
0
0
I currently finished building a Web server who's main responsibility is to simply take the contents of the body data in each http post request and write it to a log file. The contents of the post data is obfuscated when received. So i'm un obfuscating the post data and writing it to a log file on the server. The contents after obfuscated is a series of random key value pairs that differ between every request. It is not fixed data. The server is running Linux with 2.6+ kernel. Server is configured to handle heavy traffic (open files limit 32k, etc). The application is written in Python using web.py framework. The http server is Gunicorn behind Nginx. After using Apache Benchmark to do some load testing, I noticed that it can handle up to about 600-700 requests per second without any log writing issues. Linux natively does a good job at buffering. Problems start to occur when more than this many requests per second attempt to write to the same file at same moment. Data will not get written and information will be lost. I know that "the writing directly to a file" design might not have been the right solution from the get go. So i'm wondering if anyone can propose a solution that I can implement quickly without altering too much infrastructure and code that can overcome this problem? I have read about in memory storage like Redis, but I have realized that if data is sitting in memory during server failure then that data is lost. I have read in the docs that redis can be configured as a persistent store, there just needs to be enough memory on the server for Redis to do it. This solution would mean that I would have to write a script that would dump the data from Redis (memory) to the Log file at a certain interval. I am wondering if there is even a quicker solution? Any help would be greatly appreciated!
Quick writing to log file after http request
0.197375
0
0
457
15,297,322
2013-03-08T15:21:00.000
4
0
0
0
python-2.7,jenkins
15,340,482
8
true
0
0
You can query the last build timestamp to determine if the build finished. Compare it to what it was just before you triggered the build, and see when it changes. To get the timestamp, add /lastBuild/buildTimestamp to your job URL As a matter of fact, in your Jenkins, add /lastBuild/api/ to any Job, and you will see a lot of API information. It even has Python API, but I not familiar with that so can't help you further However, if you were using XML, you can add lastBuild/api/xml?depth=0 and inside the XML, you can see the <changeSet> object with list of revisions/commit messages that triggered the build
1
10
0
I am using Python 2.7 and Jenkins. I am writing some code in Python that will perform a checkin and wait/poll for Jenkins job to be complete. I would like some thoughts on around how I achieve it. Python function to create a check-in in Perforce-> This can be easily done as P4 has CLI Python code to detect when a build got triggered -> I have the changelist and the job number. How do I poll the Jenkins API for the build log to check if it has the appropriate changelists? The output of this step is a build url which is carrying out the job How do I wait till the Jenkins job is complete? Can I use snippets from the Jenkins Rest API or from Python Jenkins module?
Wait until a Jenkins build is complete
1.2
0
1
15,591
15,298,267
2013-03-08T16:07:00.000
2
0
1
0
python
15,298,354
5
false
0
0
It's probably easiest to just decode the string first, so that nothing is escaped, then re-escape the resulting string.
1
4
0
I need to put escape sequences in a string for certain characters (using double quote as an example here). For example, if I have a string abra"cada"bra, I need to generate this: abra\"cada\"bra. But if the string is already has escape characters for my interested literals (i.e double quote in this example) abra\"cada\"bra, I need to leave it alone. What is the easiest way to do it in python? (The idea is to write it to a text file which is read by another utility.)
How to inject escape sequences in python
0.07983
0
0
316
15,298,618
2013-03-08T16:24:00.000
1
0
1
0
windows,wxpython,wxwidgets,pyinstaller
15,678,526
1
true
0
1
There are a few things you may want to look into: Did you compile it as "one file"? I have heard that one exe may be blocked by some antivirus programs. It uses a few of hacks to get everything in one executable which may be considered malicious. Did you compile it as Windows app (no console)? You may want to enable console and run it on machine where it does not run at all from console. That way you may see why it crashes.
1
0
0
I am having some problems with a app we are making with wxWidget/wxPython and PyInstaller. We have compiled the app into a single exe for windows but: 1) On some machines it will not launch at all. It doesn't generate a error or anything in the app logs. It just stops almost immediately. 2) On some machines it will launch fine from cmd but not from explorer. again, same behavior. It just stops almost immediately. I don't even see it pop up in the process explorer. 3) On some machines it works just fine. Are there any tips on how I can figure out what is going wrong? Is there a way to launch a exe with a debugger?
PyInstaller Created App WIll Launch from cmd but not from explorer
1.2
0
0
374
15,299,975
2013-03-08T17:35:00.000
0
0
0
1
google-app-engine,python-2.7,google-cloud-datastore,gql
15,311,815
2
false
1
0
To add to Dan's correct answer, remember ndb and the older db are just APIs so you can seamlessly begin switching to ndb without worrying about schema changes etc.. You're question asks about switching from datastore to NDB, but you're not switching from the datastore as NDB still uses the datastore. Make sense?
1
1
0
From what I have heard, it is better to move to NDB from Datastore. I would be doing that eventually since I hope my website will be performance intensive. The question is when. My project is in its early stages. Is it better to start in NDB itself? Does NDB take care of Memcache also. So I don't need to have an explict Memcache layer?
When to transition from Datastore to NDB?
0
0
0
151
15,300,422
2013-03-08T18:04:00.000
47
0
0
0
python,database,django
17,047,519
2
false
1
0
Django relations model exposes (and documents) only OneToOneField, ForeignKey and ManyToManyField, which corresponds to the inner OneToOneField -> OneToOneRel ForeignKey -> ManyToOneRel ManyToManyField -> ManyToManyRel See source of django.db.models.fields.related for further details.
2
32
0
In django, what's the difference between a ManyToOneRel and a ForeignKey field?
Difference between ManyToOneRel and ForeignKey?
1
0
0
23,393
15,300,422
2013-03-08T18:04:00.000
41
0
0
0
python,database,django
15,300,763
2
true
1
0
ManyToOneRel is not a django.db.models.fields.Field, it is a class that is used inside Django but not in the user code.
2
32
0
In django, what's the difference between a ManyToOneRel and a ForeignKey field?
Difference between ManyToOneRel and ForeignKey?
1.2
0
0
23,393
15,304,785
2013-03-08T23:01:00.000
8
0
0
1
python,symlink,homebrew
15,304,867
5
false
0
0
You definitely do not want to do this! You may only care about Python 3, but many people write code that expects python to symlink to Python 2. Changing this can seriously mess your system up.
2
13
0
I want to install python using homebrew and I noticed there are 2 different formulas for it, one for python 2.x and another for 3.x. The first symlinks "python" and the other uses "python3". so I ran brew install python3. I really only care about using python 3 so I would like the default command to be "python" instead of having to type "python3" every time. Is there a way to do this? I tried brew switch python 3.3 but I get a "python is not found in the Cellar" error.
In homebrew how do I change the python3 symlink to only "python"
1
0
0
11,485
15,304,785
2013-03-08T23:01:00.000
1
0
0
1
python,symlink,homebrew
42,743,923
5
false
0
0
As mentioned this is not the best idea. However, the simplest thing to do when necessary is run python3 in terminal. If you need to run something for python3 then run python3
2
13
0
I want to install python using homebrew and I noticed there are 2 different formulas for it, one for python 2.x and another for 3.x. The first symlinks "python" and the other uses "python3". so I ran brew install python3. I really only care about using python 3 so I would like the default command to be "python" instead of having to type "python3" every time. Is there a way to do this? I tried brew switch python 3.3 but I get a "python is not found in the Cellar" error.
In homebrew how do I change the python3 symlink to only "python"
0.039979
0
0
11,485
15,304,934
2013-03-08T23:15:00.000
6
0
1
0
python,exception
15,304,996
5
false
0
0
I fear those come straight from the standard C library, so you'll have to look it up in your system documentation. (GLibC, Microsoft, UNIX…)
2
11
0
For a specific Exception type (let's say for IOError), how can i extract the complete list of Errnos and descriptions like this: Errno 2: No such file or directory Errno 122: Disk quota exceeded ...
How to get the list of error numbers (Errno) for an Exception type in python?
1
0
0
10,342
15,304,934
2013-03-08T23:15:00.000
4
0
1
0
python,exception
15,305,006
5
false
0
0
look for errno.h on your system.
2
11
0
For a specific Exception type (let's say for IOError), how can i extract the complete list of Errnos and descriptions like this: Errno 2: No such file or directory Errno 122: Disk quota exceeded ...
How to get the list of error numbers (Errno) for an Exception type in python?
0.158649
0
0
10,342
15,305,899
2013-03-09T00:57:00.000
3
1
1
0
python,performance
15,305,953
4
false
0
0
Python code is not executed as is, the program you typed in is compiled into an intermediate format that is optimized. So the same line can very well take different times depending on the surrounding lines. Also, Python has complex operations on its data, the time an operation takes will depend on the exact values handled.
1
2
0
For any particular bit of code, is there a way to easily get a breakdown of how long it took each line to execute?
In Python, what is the best way to determine how long each line of code takes to execute?
0.148885
0
0
2,579
15,306,231
2013-03-09T01:45:00.000
1
0
1
0
python,algorithm
15,306,292
4
false
0
0
As suggested by @airza, the itertools module is your friend. If you want to avoid using encapsulated magical goodness, my hint is to use recursion. Start playing the process of generating the lists in your mind, and when you notice you're doing the same thing again, try to find the pattern. For example: Take the first element from the first list Either take the 2nd, or the first from the other list Either take the 3rd, or the 2nd if you didn't, or another one from the other list ... Okay, that is starting to look like there's some greater logic we're not using. I'm just incrementing the numbers. Surely I can find a base case that works while changing the "first element, instead of naming higher elements? Play with it. :)
2
5
1
I want to create a function that takes in two lists, the lists are not guaranteed to be of equal length, and returns all the interleavings between the two lists. Input: Two lists that do not have to be equal in size. Output: All possible interleavings between the two lists that preserve the original list's order. Example: AllInter([1,2],[3,4]) -> [[1,2,3,4], [1,3,2,4], [1,3,4,2], [3,1,2,4], [3,1,4,2], [3,4,1,2]] I do not want a solution. I want a hint.
How to calculate all interleavings of two lists?
0.049958
0
0
1,387
15,306,231
2013-03-09T01:45:00.000
0
0
1
0
python,algorithm
15,307,850
4
false
0
0
You can try something a little closer to the metal and more elegant(in my opinion) iterating through different possible slices. Basically step through and iterate through all three arguments to the standard slice operation, removing anything added to the final list. Can post code snippet if you're interested.
2
5
1
I want to create a function that takes in two lists, the lists are not guaranteed to be of equal length, and returns all the interleavings between the two lists. Input: Two lists that do not have to be equal in size. Output: All possible interleavings between the two lists that preserve the original list's order. Example: AllInter([1,2],[3,4]) -> [[1,2,3,4], [1,3,2,4], [1,3,4,2], [3,1,2,4], [3,1,4,2], [3,4,1,2]] I do not want a solution. I want a hint.
How to calculate all interleavings of two lists?
0
0
0
1,387
15,314,025
2013-03-09T18:00:00.000
0
0
0
0
python,django,mongodb
15,498,874
1
false
1
0
You could use django-nonrel which is a fork of Django and will let you use the same ORM. If you dont want a forked Django you could use MongoEngine which has a similar syntax otherwise just raw pymongo.
1
0
0
I'm working on a Django application that needs to interact with a mongoDB instance ( preferably through django's ORM) The meat of the application still uses a relational database - but I just need to interact with mongo for a single specific model. Which mongo driver/subdriver for python will suite my needs best ?
Use MongoDB with Django but also use relational database
0
1
0
258