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...
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 "meta...
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 pr...
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. Than...
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 mb...
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, bl...
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 t...
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 t...
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 sa...
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 sa...
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 imme...
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 libto...
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...
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...
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 h...
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 d...
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 th...
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.e...
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 applica...
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 id...
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 id...
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...
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...
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 yo...
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...
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...
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...
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...
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...
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 inst...
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 trie...
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 trie...
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 trie...
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 ar...
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 ...
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 framewor...
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 ...
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 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 ...
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 w...
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 w...
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 t...
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 the...
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 ev...
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. ...
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. ...
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 ...
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 u...
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, whe...
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:...
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 soluti...
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...
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...
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 o...
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 ...
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 J...
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 co...
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 ...
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 co...
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...
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 co...
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 wh...
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 rendere...
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 adj...
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...
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 som...
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 ...
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...
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...
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 speci...
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 reso...
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. Tha...
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 wit...
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 wit...
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 wit...
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 w...
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 ...
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....
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 connect...
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 pyt...
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 ...
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 wor...
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 ...
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 importa...
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 ...
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...
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...
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 ca...
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...
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, trigr...
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 pa...
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 exe...
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 s...
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 fr...
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 plann...
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 ...
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 conten...
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 ...
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 buil...
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\...
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 c...
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 lau...
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 expli...
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" instea...
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" instea...
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 hand...
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...
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. Examp...
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. Examp...
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