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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
5,003,475 | 2011-02-15T12:11:00.000 | 0 | 0 | 0 | 0 | python,web-applications,turbogears,turbogears2 | 5,003,573 | 3 | false | 1 | 0 | I don't think so. How an ORM is suposed to persist an object to the database without any way to uniquely identify records?
However, most ORMs accept a primary_key argument so you can indicate the key if it is not explicitly defined in the database. | 3 | 0 | 0 | This relates to primary key constraint in SQLAlchemy & sqlautocode.
I have SA 0.5.1 & sqlautocode 0.6b1
I have a MySQL table without primary key.
sqlautocode spits traceback that "could not assemble any primary key columns".
Can I rectify this with a patch sothat it will reflect tables w/o primary key?
Thanks,
Vineet D... | sqlautocode : primary key required in tables? | 0 | 1 | 0 | 321 |
5,005,613 | 2011-02-15T15:27:00.000 | 0 | 1 | 1 | 0 | python | 5,005,639 | 2 | false | 0 | 0 | Python doesn't have DLLs which you can simply use with VB.net. Your fundamental understanding of the modules libraries is flawed. | 1 | 0 | 0 | I am searching to download the python dlls email, getpass, imaplib, os and use that in vb.net to get the gmail email with attachments | From where can we download the python dlls email, getpass, imaplib, os | 0 | 0 | 0 | 183 |
5,006,424 | 2011-02-15T16:30:00.000 | 0 | 0 | 1 | 0 | python,nltk | 5,009,683 | 2 | false | 0 | 0 | Where's the input paragraph coming from? File? Console? That's more of a python issue than NLTK.
For the rest, look at the nltk.tokenize module & nltk.probability.FreqDist. | 1 | 2 | 0 | I have just started using Natural Language Toolkit (NLTK) as a part of my Engineering college project. Can anybody please tell me how do I read an input paragraph text and
1) break it down into textual components i.e into number of sentences, number of words, number of characters and number of polysyllabic or complex w... | How do I find text features and print them? | 0 | 0 | 0 | 255 |
5,006,698 | 2011-02-15T16:51:00.000 | 2 | 0 | 1 | 0 | python,ruby-on-rails,ruby,documentation,language-comparisons | 5,006,748 | 4 | false | 0 | 0 | I don't believe ruby supports this. | 1 | 40 | 0 | In Python, you can access an object's docstring by using obj.__doc__. What is the equivalent action in Ruby? | What is the equivalent of a Python docstring in Ruby? | 0.099668 | 0 | 0 | 16,113 |
5,006,837 | 2011-02-15T17:01:00.000 | 0 | 1 | 0 | 1 | python,matlab,numpy | 5,007,373 | 2 | false | 0 | 0 | The shell on your system and the shell opened by Matlab when you execute the system command are not necessarily the same.
Importantly, there could be different environment variables. Try e.g. executing system('echo $PATH') to check whether you have access to all your libraries. | 1 | 0 | 0 | I have a MATLAB function that needs to communicate (not rapidly, and not often) with python code. I have MATLAB write numbers to a file. Python reads the file, does some calculations, and writes some results to another file. MATLAB then reads that file and continues on its way.
The problem I am having is when I want to... | Problem with using system call to execute python script from MATLAB | 0 | 0 | 0 | 2,383 |
5,007,455 | 2011-02-15T17:55:00.000 | 3 | 0 | 0 | 0 | python,vlc | 5,033,072 | 1 | true | 0 | 1 | Reposting my comment as an answer, since it fixed the problem:
I'm going to guess that the problem is trying to load a 32-bit DLL from a 64-bit process. You may be able to fix it by using a 32-bit Python build. | 1 | 0 | 0 | Have downloaded VLC.py, and placed it in my VLC install directory, where libvlc.dll is also present
On typing import vlc
I get the following error
Traceback (most recent call last):
File "C:\Program Files
(x86)\VideoLAN\VLC\vlc.py", line 88,
in
dll = ctypes.CDLL('libvlc.dll') File
"C:\Python27\lib\cty... | VLC Python Bindings -- Error 193 | 1.2 | 0 | 0 | 2,520 |
5,007,478 | 2011-02-15T17:57:00.000 | 0 | 0 | 0 | 0 | python,fonts,rotation,render,pygame | 5,691,673 | 2 | false | 0 | 1 | You can use a pyOpenGL surface in pygame, if that simplifies it for you.
Pyglet also uses OpenGL.
(for pygame surfaces) You can cache the rendered text, using that to rotate. Or pre-cache all 32 directions. [ see other answer ] | 1 | 0 | 0 | What's the best way to draw rotated text rendered with fonts with pygame? I can just draw the font then rotozoom it, but it seems better result would be gotten if it were possible to draw the glyphs directly rotated, especially taking AA into account? | draw rotated font with pygame | 0 | 0 | 0 | 2,142 |
5,007,900 | 2011-02-15T18:32:00.000 | 4 | 0 | 1 | 0 | python,coding-style | 5,007,952 | 2 | true | 0 | 0 | If your function is going to effectively zip the lists anyway, I would probably prefer to zip the lists in the caller. Then the caller can decide what to do if the lists are not the same length. Also, if your pairs are logically related then the caller might already have the data as a list of pairs, and it would be inc... | 2 | 3 | 0 | Is it better to pass in a zipped list of pairs, or two lists that must agree in length?
With two lists, I have to assert their lengths agree, but at least the parameters are named.
I am asking about the prevailing style. Are there any examples of choosing one over the other from major libraries? For example, I guess ... | python style question | 1.2 | 0 | 0 | 177 |
5,007,900 | 2011-02-15T18:32:00.000 | 4 | 0 | 1 | 0 | python,coding-style | 5,007,982 | 2 | false | 0 | 0 | In my opinion it depends on the semantics of the routine whether these checks must be done in the caller or in the callee. | 2 | 3 | 0 | Is it better to pass in a zipped list of pairs, or two lists that must agree in length?
With two lists, I have to assert their lengths agree, but at least the parameters are named.
I am asking about the prevailing style. Are there any examples of choosing one over the other from major libraries? For example, I guess ... | python style question | 0.379949 | 0 | 0 | 177 |
5,009,112 | 2011-02-15T20:26:00.000 | 0 | 0 | 0 | 0 | python,sqlalchemy,nosetests | 10,268,378 | 1 | false | 0 | 0 | It is my understanding that this plugin is only meant for unit testing SQLAlchemy itself and not as a general tool. Perhaps that is why there are no examples or documentation? Posting to the SQLAlchemy mailing list is likely to give you a better answer "straight from the horse's mouth". | 1 | 3 | 0 | The python unit testing framework called nosetest has a plugin for sqlalchemy, however there is no documentation for it that I can find. I'd like to know how it works, and if possible, see a code example. | How does the nosetests sqlalchemy plugin work? | 0 | 1 | 0 | 340 |
5,010,863 | 2011-02-15T23:45:00.000 | 1 | 0 | 0 | 0 | python,pylons,pyramid | 5,011,293 | 2 | false | 1 | 0 | In Pylons, each controller can have a before and after methods you can define that's then called before/after the controller method called.
There's also the lib/base.py file which contains the controller call and you could add some custom code there, but it will be called on every request and can be dangerous if your ... | 1 | 3 | 0 | Is there an event or some kind of work with middlelayer where the request is already sent to the user, but we still have the information so we can do stuff on the DB later? | Post-process request event in Pyramid/Pylons | 0.099668 | 0 | 0 | 1,412 |
5,010,906 | 2011-02-15T23:52:00.000 | 1 | 0 | 0 | 1 | python,google-app-engine | 5,012,278 | 3 | false | 1 | 0 | Assuming you are avoiding Nick's suggestion for some particular reason, the next best thing would be to include the copying process in your build system. 1 When you build your deploy target, maven/make/ant/"your favorite build tool" should check out copies of your latest revision from your source control system into s... | 1 | 2 | 0 | I have an GAE app, and I deploy it on 2 different domains, and they use separate datastores.
However, right now it is done by having two identical folders with different app.yaml configurations.
If I make changes I need to copy all files again. Is there an elegant solution for that, like having two app.yaml files in t... | Managing two instances of the same GAE application | 0.066568 | 0 | 0 | 74 |
5,011,135 | 2011-02-16T00:25:00.000 | 1 | 1 | 0 | 1 | python,tornado | 12,342,342 | 5 | true | 0 | 0 | Use Django.
I'm a hardcore Tornado fan but if you need to ask, Django is the best tool for you. Tornado is great but Django is much easier to build when you need a MySQL database thanks to its awesome ORM. | 4 | 5 | 0 | I want to use a Python framework that handles sessions (user auth), templating along with MySQL database access (although I can use MySQLdb quite nicely)
Tornado looks promising but, I just can't see how to use it. The sample given has a port listen feature. Does it replace Apache? Exactly how do I configure my server ... | python tornado setup | 1.2 | 0 | 0 | 4,348 |
5,011,135 | 2011-02-16T00:25:00.000 | 0 | 1 | 0 | 1 | python,tornado | 31,242,703 | 5 | false | 0 | 0 | If you are using tornado follow nginx. | 4 | 5 | 0 | I want to use a Python framework that handles sessions (user auth), templating along with MySQL database access (although I can use MySQLdb quite nicely)
Tornado looks promising but, I just can't see how to use it. The sample given has a port listen feature. Does it replace Apache? Exactly how do I configure my server ... | python tornado setup | 0 | 0 | 0 | 4,348 |
5,011,135 | 2011-02-16T00:25:00.000 | 1 | 1 | 0 | 1 | python,tornado | 8,414,532 | 5 | false | 0 | 0 | if you using tornado for websockets you can use ha-proxy for proxying socket request to tornado (ngnix not support this) | 4 | 5 | 0 | I want to use a Python framework that handles sessions (user auth), templating along with MySQL database access (although I can use MySQLdb quite nicely)
Tornado looks promising but, I just can't see how to use it. The sample given has a port listen feature. Does it replace Apache? Exactly how do I configure my server ... | python tornado setup | 0.039979 | 0 | 0 | 4,348 |
5,011,135 | 2011-02-16T00:25:00.000 | 0 | 1 | 0 | 1 | python,tornado | 7,278,376 | 5 | false | 0 | 0 | If you setup tornado via LAMP (apache with mod_wsgi for example) you will lose every single async option in tornado, significant amount of memory and speed.
It's highly recomended to use nginx for serving static files and proxying dynamic requests to the tornado application instance. | 4 | 5 | 0 | I want to use a Python framework that handles sessions (user auth), templating along with MySQL database access (although I can use MySQLdb quite nicely)
Tornado looks promising but, I just can't see how to use it. The sample given has a port listen feature. Does it replace Apache? Exactly how do I configure my server ... | python tornado setup | 0 | 0 | 0 | 4,348 |
5,012,257 | 2011-02-16T03:31:00.000 | 1 | 0 | 0 | 0 | python,wxpython,boxsizer | 5,018,264 | 1 | false | 0 | 1 | For complex layouts, I sketch it out on a piece of paper. Then I draw boxes around the widgets in different ways to decide what sizers to use. You can nest pretty much any sizer inside another one. If the controls naturally fit in a grid, then using a grid sizer of some sort is probably alright. If not, then use BoxSiz... | 1 | 1 | 0 | I have a wxPython app with one frame and one panel. On that panel are a number of static boxes, each of which has buttons and textboxes.
I have just begun reading about sizers, but they seem like they might be more than what I need, or it could that they are exactly what I need but I don't know how to use them correct... | Simple wxPython Frame Contents Resizing - Ratio? | 0.197375 | 0 | 0 | 301 |
5,012,560 | 2011-02-16T04:32:00.000 | 2 | 0 | 1 | 0 | python,random,seed | 5,012,654 | 7 | false | 0 | 0 | The seed is an internal variable in the random package which is used to create the next random number. When a new number is requested, the seed is updated, too.
I would simple use 0 as a seed if you want to be sure to have the same random numbers every time, or make i configurable.
CorelDraw once had a random pattern... | 1 | 59 | 0 | Is there any way to find out what seed Python used to seed its random number generator?
I know I can specify my own seed, but I'm quite happy with Python managing it. But, I do want to know what seed it used, so that if I like the results I'm getting in a particular run, I could reproduce that run later. If I had the... | how to query seed used by random.random()? | 0.057081 | 0 | 0 | 41,980 |
5,013,599 | 2011-02-16T07:22:00.000 | 1 | 1 | 1 | 1 | python,linux,shell,command-line,unicode | 5,013,663 | 4 | false | 0 | 0 | if your application doesn't really deal with a whole lot of internationalisation, ascii should suffice. but if not, i'd say utf-8 or better still utf-16 should be the order of the day. | 2 | 7 | 0 | I have a command line program written in Python, and when I pipe it through another program on the command line, sys.stdout.encoding is None. This makes sense, I suppose -- the output could be another program, or a file you're redirecting it into, or whatever, and it doesn't know what encoding is desired. But neither... | If a command line program is unsure of stdout's encoding, what encoding should it output? | 0.049958 | 0 | 0 | 430 |
5,013,599 | 2011-02-16T07:22:00.000 | 0 | 1 | 1 | 1 | python,linux,shell,command-line,unicode | 5,013,662 | 4 | false | 0 | 0 | You should output UTF-8 because thats what everyone should be using. It's a bug not to be. ;) | 2 | 7 | 0 | I have a command line program written in Python, and when I pipe it through another program on the command line, sys.stdout.encoding is None. This makes sense, I suppose -- the output could be another program, or a file you're redirecting it into, or whatever, and it doesn't know what encoding is desired. But neither... | If a command line program is unsure of stdout's encoding, what encoding should it output? | 0 | 0 | 0 | 430 |
5,013,863 | 2011-02-16T07:56:00.000 | 4 | 1 | 0 | 0 | php,python,ruby,groovy,reloading | 5,014,150 | 2 | false | 1 | 0 | I think you're making a bigger deal out of this than it really is.
Any application for which it is that important that it never be down for 1/2 a minute (which is all it takes to reboot a server to pick up a file change) really needs to have multiple application server instances in order to handle potential failures of... | 1 | 5 | 0 | This has been bugging me for awhile now.
In a deployed PHP web application one can upload a changed php script and have the updated file picked up by the web server without having to restart.
The problem? Ruby, Groovy, & Python, etc. are all "better" than PHP in terms of language expressiveness, concision, power, ...... | 2011 Web Scripting Languages and Dynamic Reloading | 0.379949 | 0 | 0 | 368 |
5,014,427 | 2011-02-16T09:02:00.000 | 0 | 0 | 0 | 0 | python,itunes,usb-drive,playlist | 18,925,329 | 3 | false | 0 | 0 | Ciao Matteo,
You probably have a solution by now, but how about plain old drag and drop ?
1) Create playlist of all songs to copy
2) Select all drag and drop onto USB
3) Rename/retag as needed
I wrote a couple of extensions to iTunes, so if the above does not help, let me know.
Simone | 1 | 0 | 0 | I want to write a program in Python which would allow me to populate a folder with mp3 files extracted from an iTunes playlist.
Here's why: my car has a stereo which can read USB drives, so I want to populate my USB drive with my favourite songs which are already organized in iTunes.
Is that possibile? I've checked iT... | Extract mp3 path from a iTunes playlist | 0 | 0 | 0 | 441 |
5,014,485 | 2011-02-16T09:08:00.000 | 0 | 0 | 0 | 0 | python,django,proxy,mp3,soundcloud | 5,014,850 | 2 | false | 1 | 0 | I don't think it's possible. It should already be entirely up to the browser. For example Opera asks user weather to open it or download.
You could embed them in your site using their Embeded Code.
EDIT:
Nope you can't even use the link provided by the header since they've worked around hotlinking. Each download is ass... | 2 | 2 | 0 | Public Soundcloud track urls force a download upon browsing to them by utilizing a Content-Disposition header (I think.. ) which triggers a download for a known mime-type. Is there a way to proxy (create a passthrough for) these urls and strip this header from my request. I want to avoid serving the mp3 myself but I d... | Can my django app act as a header-stripping proxy? | 0 | 0 | 0 | 347 |
5,014,485 | 2011-02-16T09:08:00.000 | 2 | 0 | 0 | 0 | python,django,proxy,mp3,soundcloud | 5,038,974 | 2 | true | 1 | 0 | Technically it is entirely possible that you could request the file from the server and connect that incoming data to an output stream response in your view, thereby allowing you to control the headers that your client's browser receives so that it does not ask them to save the file.
I'm going to recommend against this... | 2 | 2 | 0 | Public Soundcloud track urls force a download upon browsing to them by utilizing a Content-Disposition header (I think.. ) which triggers a download for a known mime-type. Is there a way to proxy (create a passthrough for) these urls and strip this header from my request. I want to avoid serving the mp3 myself but I d... | Can my django app act as a header-stripping proxy? | 1.2 | 0 | 0 | 347 |
5,014,847 | 2011-02-16T09:46:00.000 | 2 | 0 | 0 | 0 | python,django | 5,014,866 | 1 | true | 1 | 0 | Check your .po files, in particular the one for the current language; the encoding may be declared incorrectly. | 1 | 0 | 0 | Hi
I've upgraded my django version to 1.2.5 and my app stopped working. The error I'm getting now is as follows:
Caught DjangoUnicodeDecodeError while
rendering: 'ascii' codec can't decode
byte 0xc3 in position 13: ordinal not
in range(128). You passed in
()
So far I've been unsuccessful in debugging this p... | Unicode conversion error with django | 1.2 | 0 | 0 | 267 |
5,014,993 | 2011-02-16T10:02:00.000 | 0 | 0 | 0 | 0 | python,scroll,zooming,transform,pygame | 13,349,846 | 3 | false | 0 | 1 | For a game that I have never finished I used trigonometry to get the new drawing positions with a freely zoomed and turned camera (bit complicated). It didn't really take to much time to calculate but I think it is more efficient to use other libraries. But if you want some examples just ask. | 2 | 5 | 0 | Im currently working on a project with pygame and am in need of being able to view part of a surface, moving around, zooming in and out ect
Can anyone recommend a way of achieving this efficently, i have it working in a convoluted method at the moment but it is too slow and reduces the game to about 1fps when zoomed ou... | Pygame zooming/scrolling window | 0 | 0 | 0 | 7,328 |
5,014,993 | 2011-02-16T10:02:00.000 | 0 | 0 | 0 | 0 | python,scroll,zooming,transform,pygame | 7,509,780 | 3 | false | 0 | 1 | You can use pygame with OpenGL, since you are already familiar with pygame. Otherwise pyglet is a similar opengl library. | 2 | 5 | 0 | Im currently working on a project with pygame and am in need of being able to view part of a surface, moving around, zooming in and out ect
Can anyone recommend a way of achieving this efficently, i have it working in a convoluted method at the moment but it is too slow and reduces the game to about 1fps when zoomed ou... | Pygame zooming/scrolling window | 0 | 0 | 0 | 7,328 |
5,016,186 | 2011-02-16T12:05:00.000 | 14 | 0 | 1 | 0 | python,numpy | 26,004,476 | 7 | false | 0 | 0 | In the numpy README.txt file, it says
After installation, tests can be run with:
python -c 'import numpy; numpy.test()'
This should be a sufficient test for proper installation. | 2 | 41 | 0 | I'm writing Python code. I want to check if numpy and wxpython are installed on machine. How to do that?? | How to detect if numpy is installed | 1 | 0 | 0 | 125,232 |
5,016,186 | 2011-02-16T12:05:00.000 | 3 | 0 | 1 | 0 | python,numpy | 24,731,828 | 7 | false | 0 | 0 | If you use eclipse, you simply type "import numpy" and eclipse will "complain" if doesn't find. | 2 | 41 | 0 | I'm writing Python code. I want to check if numpy and wxpython are installed on machine. How to do that?? | How to detect if numpy is installed | 0.085505 | 0 | 0 | 125,232 |
5,021,417 | 2011-02-16T19:53:00.000 | 1 | 0 | 1 | 0 | python,exception | 5,021,496 | 1 | true | 0 | 0 | Small methods which do not use try...catch, but are used in larger methods/functions which wrap them in try...catch is the usual solution.
This would easily allow tests to check the exceptions. | 1 | 0 | 0 | Say I have some complex code where I have nested try blocks with the generic except Exception, e because I need to isolate certain (sometimes unknown) failures from causing a long running program to halt.
Those failures are usually not important enough to halt the program, but I want to catch them so I can log them a... | Python - Is isolation via generic try blocks bad? | 1.2 | 0 | 0 | 162 |
5,021,921 | 2011-02-16T20:48:00.000 | 3 | 0 | 0 | 0 | python,numpy,scipy,data-fitting | 5,022,089 | 4 | false | 0 | 0 | Except, a spline does not give you a "formula", at least not unless you have the wherewithal to deal with all of the piecewise segments. Even then, it will not be easily written down, or give you anything that is at all pretty to look at.
A simple spline gives you an interpolant. Worse, for 3000 points, an interpolatin... | 2 | 1 | 1 | I am looking for a "method" to get a formula, formula which comes from fitting a set of data (3000 point). I was using Legendre polynomial, but for > 20 points it gives not exact values. I can write chi2 test, but algorithm needs a loot of time to calculate N parameters, and at the beginning I don't know how the functi... | large set of data, interpolation | 0.148885 | 0 | 0 | 2,988 |
5,021,921 | 2011-02-16T20:48:00.000 | 0 | 0 | 0 | 0 | python,numpy,scipy,data-fitting | 5,022,008 | 4 | false | 0 | 0 | The only formula would be a polynomial of order 3000.
How good does the fit need to be? What type of formula do you expect? | 2 | 1 | 1 | I am looking for a "method" to get a formula, formula which comes from fitting a set of data (3000 point). I was using Legendre polynomial, but for > 20 points it gives not exact values. I can write chi2 test, but algorithm needs a loot of time to calculate N parameters, and at the beginning I don't know how the functi... | large set of data, interpolation | 0 | 0 | 0 | 2,988 |
5,022,891 | 2011-02-16T22:25:00.000 | 1 | 0 | 0 | 0 | python,python-imaging-library,cairo | 5,024,687 | 2 | true | 0 | 1 | You can do this entirely with PIL if you start with a single pre-made white-to-black gradient image (that you've made in some other program) and then use the ImageChops module to manipulate this together with your primary image to get what you want.
For example to if you want to fade from red to blue: multiply red by t... | 1 | 1 | 0 | I am trying automatically generate buttons to a menu using PIL in python.
The button should be small rectangular and have a little gradient from one color to another, and a little text in it.
Is PIL the best way to do this, or is Cairo a better alternative? Any suggestion to how I can accomplish this without having a i... | Generating a shaded button using PIL | 1.2 | 0 | 0 | 413 |
5,023,846 | 2011-02-17T00:27:00.000 | 1 | 0 | 0 | 0 | python,scipy,histogram,gaussian,least-squares | 34,021,509 | 3 | false | 0 | 0 | I got in trouble with this issue too, but I solved it in my project. I'm not sure if this is a general solution.
The reason was that the scipy.optimize.fmin_slsqp calculated the gradient by an approximate approach when the argument jac is set by False or default. The gradient produced from the approximate approach was ... | 3 | 5 | 1 | Has anybody ever encountered problems with fmin_slsqp (or anything else in scipy.optimize) only when using very large or very small numbers?
I am working on some python code to take a grayscale image and a mask, generate a histogram, then fit multiple gaussians to the histogram. To develop the code I used a small samp... | Problem with scipy.optimize.fmin_slsqp when using very large or very small numbers | 0.066568 | 0 | 0 | 5,001 |
5,023,846 | 2011-02-17T00:27:00.000 | 4 | 0 | 0 | 0 | python,scipy,histogram,gaussian,least-squares | 5,690,969 | 3 | false | 0 | 0 | Are you updating your initial guess ("x0") when your underlying data changes scale dramatically? for any iterative linear optimization problem, these problems will occur if your initial guess is far from the data you're trying to fit. It's more of a optimization problem than a scipy problem. | 3 | 5 | 1 | Has anybody ever encountered problems with fmin_slsqp (or anything else in scipy.optimize) only when using very large or very small numbers?
I am working on some python code to take a grayscale image and a mask, generate a histogram, then fit multiple gaussians to the histogram. To develop the code I used a small samp... | Problem with scipy.optimize.fmin_slsqp when using very large or very small numbers | 0.26052 | 0 | 0 | 5,001 |
5,023,846 | 2011-02-17T00:27:00.000 | 5 | 0 | 0 | 0 | python,scipy,histogram,gaussian,least-squares | 8,394,696 | 3 | false | 0 | 0 | I've had similar problems optimize.leastsq. The data I need to deal with often are very small, like 1e-18 and such, and I noticed that leastsq doesn't converge to best fit parameters in those cases. Only when I scale the data to something more common (like in hundreds, thousands, etc., something you can maintain reso... | 3 | 5 | 1 | Has anybody ever encountered problems with fmin_slsqp (or anything else in scipy.optimize) only when using very large or very small numbers?
I am working on some python code to take a grayscale image and a mask, generate a histogram, then fit multiple gaussians to the histogram. To develop the code I used a small samp... | Problem with scipy.optimize.fmin_slsqp when using very large or very small numbers | 0.321513 | 0 | 0 | 5,001 |
5,024,478 | 2011-02-17T02:33:00.000 | 1 | 0 | 0 | 1 | python,networking,ip-address,static-ip-address | 5,642,044 | 3 | false | 0 | 0 | This is so bad in so many ways I can't even explain how awfull this is.
Why do you want this? Could you please tell us that, and we could come up with a much better answer than this utterly uggly "sollution"?
If you have a Linux/Unix system, you can make your DHCP client to request the DHCP-server to give you a specif... | 1 | 1 | 0 | How to check the availability of an IP address in python?
For example, I wan't to change my system's IP address to 192.168.112.226 statically overriding the dhcp provided address. The default gateway is 192.168.112.1. But I wan't to check before if anyone is using 192.168.112.226 before assigning to myself.
Usually do ... | Availability of IP Address - Python | 0.066568 | 0 | 0 | 4,550 |
5,025,579 | 2011-02-17T05:59:00.000 | 0 | 0 | 0 | 0 | python,svn,urllib,sys.path | 5,037,759 | 4 | false | 0 | 0 | I just got the answer. I'll use the Pysvn to checkout the repo to a local folder. And I'll add the folder to sys.path list. Using this I can access the folders module.
Thank everyone for helping me out
But I've a slight problem... I didn't had the admin right in my office computer(I'm using windows) so I installed the... | 1 | 2 | 0 | I've made a python module file and uploaded in the SVN Repo (say string_utl.py which does string related operation). Is the anyway that I can access the the file Direclty for the SVN. Though I checkout the file Locally from the SVN to my computer and access it from there. But that not the point. I'm thinking of a local... | Is there anyway I can access File from Online SVN in python? | 0 | 0 | 1 | 4,844 |
5,025,770 | 2011-02-17T06:31:00.000 | 4 | 1 | 0 | 1 | java,python,http,asynchronous,nonblocking | 5,049,188 | 1 | false | 1 | 0 | Nonblocking servers are the best choice provided all your libraries provides nonblocking apis. As mentioned in your second question if a library blocks (eg database lib making a blocking call), the entire process/thread blocks and the system hangs. Not all of the libraries available are asynchronous which makes it dif... | 1 | 4 | 0 | Hi
I am trying to Understand if tornado/eventlet based http sever are better than threaded sever. While goggling the subject I am seeing that these are single thread event base server which run a single handler function after select/poll/epoll on socket.
My first question is that is this tornado/eventlet similar to n... | Non-blocking http server , java nio , python tornado eventlet | 0.664037 | 0 | 0 | 2,292 |
5,027,371 | 2011-02-17T09:56:00.000 | 0 | 0 | 0 | 1 | python,google-app-engine,logging | 5,035,952 | 1 | false | 1 | 0 | Add a single logging.debug call in your authentication code to log the current user. Logs are shown aggregated by request, so you'll always be able to see the user associated with that request. | 1 | 1 | 0 | I use a custom authentication for my python Google App Engine app.
There is a "username" field in the log for every request, which is empty now. Is it possible to add the name of the authenticated user to the log? I would not like to add an "user: %s" % user.name manually to all of my logging.xxx statements.
Thanks. | Google App Engine log username with custom auth | 0 | 0 | 0 | 252 |
5,028,075 | 2011-02-17T11:02:00.000 | 1 | 0 | 0 | 1 | python,installation,distutils | 7,715,650 | 2 | false | 0 | 0 | For distutils, we are working on support to install scripts into prefix/sbin. | 1 | 5 | 0 | Commonly on most unix systems there is a distinction between $PREFIX/bin and $PREFIX/sbin. When installing a piece of software the administrator decides about what $PREFIX is, but the author decides which programs are suitable for regular users and which are not. With Python's distutils a set of scripts can be defined ... | How to install scripts to sbin with python's distutils? | 0.099668 | 0 | 0 | 2,055 |
5,028,536 | 2011-02-17T11:49:00.000 | 0 | 0 | 0 | 0 | java,php,python,macros,xls | 5,028,703 | 1 | true | 0 | 0 | It's your "excel sheets with macros" that is going to cause you all end of problems. If you're on a Windows platform, with Excel installed, then PHP's COM extension should allow you to do this. Otherwise, I'm nor aware of any PHP library which allows you to create macros... not even PHPExcel. I suspect the same will ap... | 1 | 0 | 0 | We have a system which generates reports in XLS using Spreadsheet_Excel_Writer for smaller files and in case of huge files we just export them as CSVs.
We now want to export excel sheets which are multicolor etc. as a part of report generation, which in excel could be done through a few macros.
Is there any good e... | Good xls exporter to generate excel sheets automatically with a few macros from any programming language? | 1.2 | 1 | 0 | 515 |
5,028,731 | 2011-02-17T12:09:00.000 | -1 | 0 | 0 | 0 | python,django | 5,038,378 | 4 | false | 1 | 0 | Similar to maersu's solution, but if you have a ModelForm with a model that has a ForeignKey to another model, you may want to assign to the field's queryset instead of choices. | 1 | 9 | 0 | I want to set choices in dynamic.
I used __set_choices method but, when request method is POST,
is_valid method always return False.
if request.method=='POST':
_form = MyForm(request.POST)
if _form.is_valid():
#something to do | How to set choices in dynamic with Django choicefield? | -0.049958 | 0 | 0 | 13,979 |
5,029,415 | 2011-02-17T13:16:00.000 | 4 | 1 | 0 | 0 | python,django,testing,performance,fixtures | 5,029,483 | 2 | false | 1 | 0 | You may use sqlite in-memory database for tests - it really fast | 2 | 9 | 0 | my Django tests run really slowly, but it's not the test's fault.
At the moment, the whole process takes 14s, but only 0.1s of that is running tests. The first few seconds are creating tables & indexes, the rest is applying the project's many fixtures.
What's the best way to deal with this? I think there is a way of sp... | What's the best way to optimise the fixture-loading part of Django tests? | 0.379949 | 0 | 0 | 1,206 |
5,029,415 | 2011-02-17T13:16:00.000 | 4 | 1 | 0 | 0 | python,django,testing,performance,fixtures | 5,029,700 | 2 | true | 1 | 0 | "but I need most of them to do most tests"...
Sorry about this, but to speed things up you're going to have to do some thinking.
"I think there is a way of specifying which fixtures to load in each test"
This is a disturbing thing to read. Have you looked at your tests recently?
Your tests do -- specifically ... | 2 | 9 | 0 | my Django tests run really slowly, but it's not the test's fault.
At the moment, the whole process takes 14s, but only 0.1s of that is running tests. The first few seconds are creating tables & indexes, the rest is applying the project's many fixtures.
What's the best way to deal with this? I think there is a way of sp... | What's the best way to optimise the fixture-loading part of Django tests? | 1.2 | 0 | 0 | 1,206 |
5,029,880 | 2011-02-17T13:59:00.000 | 2 | 0 | 0 | 1 | python,process,popen | 5,030,603 | 2 | false | 0 | 0 | Assuming you want to communicate with the "subprocess" and must do so using its standard i/o streams, you could create a wrapper around the executable that maps its stdin/out/err to a socket or named pipe.
The program that intends to control the "subprocess" can then start and stop communications at any time. You may h... | 2 | 3 | 0 | I would like to create an subprocess.Popen object from an already running process... Is that possible somehow?
Another idea would be to serialize (pickle) the subprocess object and write it to a database so that if the main process restarts it could get the subprocess.Popen objects back from the database. I'm unsure if... | create subprocess object from already running process | 0.197375 | 0 | 0 | 2,491 |
5,029,880 | 2011-02-17T13:59:00.000 | 2 | 0 | 0 | 1 | python,process,popen | 5,030,048 | 2 | false | 0 | 0 | create an subprocess.Popen object from an already running process
Do you mean from an already running sub-process? The only way I know of to pass objects between processes is to pickle them and write them out either to a file or a database as you suggested.
Typically, sub-processes cannot be spawned from already runnin... | 2 | 3 | 0 | I would like to create an subprocess.Popen object from an already running process... Is that possible somehow?
Another idea would be to serialize (pickle) the subprocess object and write it to a database so that if the main process restarts it could get the subprocess.Popen objects back from the database. I'm unsure if... | create subprocess object from already running process | 0.197375 | 0 | 0 | 2,491 |
5,030,586 | 2011-02-17T14:58:00.000 | 1 | 0 | 0 | 1 | python,winforms,global-variables | 5,031,228 | 2 | true | 0 | 0 | Easiest solution is probably to just have the python script print to stdout: say each time an item is processed, print a line with a number representing how many items have been processed (or a percentage). Then have the forms application read the output line by line, updating the progressbar based on that information. | 1 | 3 | 0 | I am trying to figure out an elegant way to share a variable between a windows form app and a python script running in the background. The variable would be used solely to update a progress bar in the windows form based on the the long running process in the python script. More specifically, a windows timer will fire... | Elegant Way To Share Variable Between Windows Form and Python Script Running In Background Process | 1.2 | 0 | 0 | 580 |
5,030,919 | 2011-02-17T15:26:00.000 | 1 | 0 | 0 | 0 | python,binary | 5,035,062 | 5 | false | 0 | 0 | Consider using
struct.unpack(byteorder + str(len(rawbytes) // 2) + "h", rawbytes)
where byteorder is '<' or '>' as desired, and similarly for packing. Note: I'm not claiming that this is faster than the array way, but I do note that the array way sometimes needs an additional byteswap step. | 1 | 8 | 0 | I have to read and write binary data, where each element of data:
size = 2 bytes (16 bit)
encoding = signed 2's complement
endiannes = big or little (must be
selectable)
Is it possible without using any external module? If yes,
How to read such data from a binary
file using read() into an array L of
integers?... | How to read/write binary 16-bit data in Python 2.x? | 0.039979 | 0 | 0 | 16,839 |
5,032,139 | 2011-02-17T17:08:00.000 | 1 | 0 | 0 | 0 | python,django,manage.py | 5,032,229 | 1 | true | 1 | 0 | have you run manage.py runserver and if you have, then try python manage.py runserver? | 1 | 0 | 0 | I'm sure I'm overlooking something very simple, but I've tried multiple times and still run into the same problem.
I have installed Python 2.7.1 and Django 1.2.4 on Windows Vista.
I create a project using django-admin startproject projectname. It successfully creates the folders and files needed.
I then try running man... | Django manage.py only returning list of subcommands and options | 1.2 | 0 | 0 | 1,622 |
5,032,947 | 2011-02-17T18:24:00.000 | 2 | 0 | 0 | 0 | python,pdf,pdf-generation,reportlab | 5,034,474 | 2 | false | 0 | 0 | canvas.draw() is too low level. If you want to stick with canvas.draw you have to take care of everything.
Instead, use Platypus and make Flowables, when you place them in your document reportlab.platypus.doctemplate.BaseDocTemplate has several hooks you can use to control placement and flux. | 1 | 1 | 0 | I am creating PDFs tables with Reportlib (with c.draw() ). I don´t know, when the page is full because of the dynamic content. How can I check out, if I am at the end of the page, so that I can add an footer and do c.showPage() ? | How can I find out, if a page is full with reportlab PDF? | 0.197375 | 0 | 0 | 665 |
5,032,956 | 2011-02-17T18:25:00.000 | 27 | 0 | 1 | 0 | python,django,windows-7 | 5,033,019 | 2 | true | 0 | 0 | I recommend the 32-bit one unless you are going to exhaust the address space. Many third-party modules like OpenCV and Numpy are considerably easier to install with 32-bit Python. (You can build those modules from source to get them to work with 64-bit Python but that's probably more time and effort than necessary in m... | 1 | 22 | 0 | I am setting up Django, and am trying to decide whether to use the 32 bit or 64 bit version of Python 2.7 on my Windows 7 machine.
I've seen the issues with the 64 bit installer, but the real question is whether or not all of the necessary libraries are available for 64 bit, or whether one version has any other issues ... | Should I use Python 2.7 32 bit or 64 bit with Windows 7 | 1.2 | 0 | 0 | 9,022 |
5,034,772 | 2011-02-17T21:17:00.000 | 2 | 0 | 1 | 0 | python,recursion,stack | 5,034,876 | 5 | false | 0 | 0 | Python limits the depth of recursion to a value you can find out by calling sys.getrecursionlimit and change by calling sys.setrecursionlimit. The default value isn't terribly big. If you set it too high, then you can end up blowing out the C stack when Python recurses. How high "too high" is is platform-dependent, tho... | 1 | 2 | 0 | I'm working on an AI homework, and despite my professor's suggestions, I have no intention of writing this assignment in lisp. However, I do want to write it recursively, the better to keep it concise and simple. Here is my question:
Am I running a major risk of running out of stack space if I perform a search over a ... | How safe is recursion in Python? | 0.07983 | 0 | 0 | 4,022 |
5,035,203 | 2011-02-17T21:59:00.000 | 1 | 0 | 0 | 0 | python,django,amazon-s3,wav,waveform | 5,035,338 | 2 | false | 1 | 0 | It would make sense to do the work on your side and then upload to Amazon S3. You should be able to use Boto, or any other library by importing the library. | 1 | 1 | 0 | I have a web project where users are uploading .wav files. I want to generate a waveform image from the .wav file once it's uploaded. But generally for storage, I want to use Amazon S3. Thing is, I want to use something like TimeSide (http://code.google.com/p/timeside/wiki/PythonApi) to generate the waveform image from... | In Django, a way for user to upload file to server, then move to Amazon S3? | 0.099668 | 0 | 0 | 714 |
5,035,348 | 2011-02-17T22:14:00.000 | 4 | 0 | 0 | 0 | python,django,django-forms,django-authentication,voting | 5,036,260 | 2 | true | 1 | 0 | To address your concerns:
1: a simple Captcha would probably do the trick, if you google "django captcha", there are a bunch of plugins. I've never used them myself, so I can't say which is the best.
2 & 3: Using Django's sessions addresses both of these problems - with it you could save a cookie on the user's browse... | 1 | 6 | 0 | We are considering implementing a voting system (up, down votes) without using any type of credentials--no app accounts nor OpenID or anything of that sort.
Concerns in order:
Prevent robot votes
Allow individuals under a NAT to vote without overriding/invalidating someone else's vote
Preventing (or, at the very least... | Designing a Django voting system without using accounts | 1.2 | 0 | 0 | 1,261 |
5,035,460 | 2011-02-17T22:24:00.000 | 0 | 1 | 0 | 0 | python | 5,035,919 | 1 | true | 0 | 0 | There are a bunch of different ways of handling this, depending on exactly what you are trying to save and how you want to use it.
If you want to save basic unit-type stats so they can be easily modified, a plain-text file or csv file would work nicely. (If you have a copy of the game Alpha Centauri, look at the factio... | 1 | 0 | 0 | I want to make units fight in space just to try out some stuff it would need to print whats going on and results. I'm planing on loading each unit from a separate file or similar (units will be modifiable so i think it should be better this way, no need to keep each unit stats for instancing). I'm not sure how i would ... | How to make RTS units | 1.2 | 0 | 0 | 375 |
5,036,118 | 2011-02-17T23:44:00.000 | 0 | 0 | 0 | 0 | python,orm,sqlalchemy | 5,037,471 | 1 | false | 1 | 0 | Sqlalchemy-migrate (http://packages.python.org/sqlalchemy-migrate/) is intended to help do these types of operations. | 1 | 0 | 0 | Basically I'm looking for an equivalent of DataMapper.auto_upgrade! from the Ruby world.
In other words:
change the model
run some magic -> current db schema is investigated and changed to reflect the model
profit
Of course, there are cases when it's impossible for such alteration to be non-desctructive, eg. when you... | Can SQLAlchemy do a non-destructive alter of the db comparing the current model with db schema? | 0 | 1 | 0 | 220 |
5,038,022 | 2011-02-18T05:40:00.000 | 0 | 0 | 0 | 0 | python,wxpython,computer-architecture | 5,039,125 | 3 | false | 0 | 1 | wxPython and PyQt both are good option. I find Qt easy as compare to wxPython. | 2 | 3 | 0 | For a computer architecture assignment, I am trying to replace a C++ library called "Sim" with something in Python.
I am already using MyHDL for the simulator, but the C++ program has a nice interactive feature that lets students see the components connected together (gates, inputs, outputs, flip flops, etc.) and toggl... | Is wxPython good for a Hardware Simulator? | 0 | 0 | 0 | 441 |
5,038,022 | 2011-02-18T05:40:00.000 | 1 | 0 | 0 | 0 | python,wxpython,computer-architecture | 5,038,058 | 3 | false | 0 | 1 | wxPython or pyside (Qt python bindings) are both ideal for this.
wx is a little better if you have any MFC experience, Qt is perhaps a more modern design. | 2 | 3 | 0 | For a computer architecture assignment, I am trying to replace a C++ library called "Sim" with something in Python.
I am already using MyHDL for the simulator, but the C++ program has a nice interactive feature that lets students see the components connected together (gates, inputs, outputs, flip flops, etc.) and toggl... | Is wxPython good for a Hardware Simulator? | 0.066568 | 0 | 0 | 441 |
5,038,255 | 2011-02-18T06:18:00.000 | 0 | 1 | 0 | 0 | python,file,rtp | 5,039,698 | 2 | false | 0 | 0 | FTP Tunneled over SSH.
Use twisted and a good linux shell. | 1 | 0 | 0 | I want to create an application which needs from time to time do
file transfer (I want to write the server as well as the client).
What is the best way to do this file transfer?
Thanks in advance..
Nimmy... | Real Time File Transfer using python script | 0 | 0 | 0 | 662 |
5,040,388 | 2011-02-18T10:50:00.000 | 0 | 0 | 0 | 0 | python,web-crawler,scrapy | 12,648,771 | 2 | false | 1 | 0 | I store all data in database as well, and calculate a hash value out of the data. That way you can look up the hash very quickly, and carry out de-dup operation on the fly. | 2 | 0 | 0 | I'm doing a RSS spider. How do you do for controlling the last crawl
date?
Right now what was I thinking is this:
Put in a control file the last pub_date that I have crawled.
Then when the crawl starts, it checks the last pub_date against the
new pub_dates. If there are new items, then start crawling, if not, do
noth... | Scrapy: RSS control pub_date | 0 | 0 | 1 | 231 |
5,040,388 | 2011-02-18T10:50:00.000 | 1 | 0 | 0 | 0 | python,web-crawler,scrapy | 5,042,647 | 2 | false | 1 | 0 | I store all data in the database (including last crawl date and post dates) and take all dates I need from database. | 2 | 0 | 0 | I'm doing a RSS spider. How do you do for controlling the last crawl
date?
Right now what was I thinking is this:
Put in a control file the last pub_date that I have crawled.
Then when the crawl starts, it checks the last pub_date against the
new pub_dates. If there are new items, then start crawling, if not, do
noth... | Scrapy: RSS control pub_date | 0.099668 | 0 | 1 | 231 |
5,040,412 | 2011-02-18T10:54:00.000 | 2 | 0 | 0 | 0 | python,matplotlib | 5,040,977 | 8 | false | 0 | 0 | From your comments to other answers, you seem to already get the set of points defining the convex hull, but they're not ordered. The easiest way to order them would be to take a point inside the convex hull as the origin of a new coordinate frame. You then transform the (most probably) Cartesian coordinates of your po... | 1 | 9 | 1 | So, i have a set of points (x,y), and i want to be able to draw the largest polygon with these points as vertices. I can use patches.Polygon() in matplotlib, but this simply draws lines between the points in the order i give them. This doesn't automatically do what i want. As an example, if a want to draw a square, and... | How to draw the largest polygon from a set of points | 0.049958 | 0 | 0 | 5,735 |
5,043,327 | 2011-02-18T15:44:00.000 | 2 | 0 | 0 | 0 | python,sqlite,sqlalchemy,nfs | 5,095,693 | 1 | false | 0 | 0 | SQLite NFS issues are due to broken caching and locking. If your process is the only one accessing the file on NFS then you'll be ok.
The SQLite backup API was designed to solve exactly your problem. You can either backup directly to the NFS database or to another local temp file and then copy that. The backup API d... | 1 | 3 | 0 | I have recently converted my workspace file format for my application to sqlite. In order to ensure robust operation on NFS I've used a common update policy, I do all modifications to a copy stored in a temp location on the local harddisk. Only when saving do I modify the original file (potentially on NFS) by copying... | How to ensure a safe file sync with sqlite and NFS | 0.379949 | 1 | 0 | 2,749 |
5,044,073 | 2011-02-18T16:48:00.000 | 6 | 0 | 0 | 0 | python,keyboard-events | 5,047,120 | 4 | false | 0 | 1 | Short answer: no
Keypresses are system-dependent. They are interrupt-driven. They one of the basic things built into most modern OSes. They have different philosophies that can't be unified in a generic way without losing functionality.
you might try-
termios = unix, posix-style file-descriptor driven
curses = por... | 1 | 21 | 0 | I need to listen for certain keypresses in a python terminal program without pausing execution with raw_input. I've seen people use a few windows specific ways of listening for keystrokes and I've seen people use large modules like tkinter and pygame which I want to avoid.
Is there a lightweight module out there that d... | Python cross-platform listening for keypresses? | 1 | 0 | 0 | 20,515 |
5,044,083 | 2011-02-18T16:49:00.000 | 0 | 0 | 1 | 0 | python,python-imaging-library | 5,044,136 | 1 | false | 0 | 0 | Oops, just realized you can do image.crop() and it will resize the image for you. | 1 | 1 | 0 | I am trying to increase the height of an image using PIL but I don't want the image to be resized; I actually want a strip of blank pixels at the bottom of the image. Any way of doing this with PIL?
I guess one way would be to make a new image of the required size and copy the old image into it but I can't seem to find... | extending an image with Python Imaging Library | 0 | 0 | 0 | 238 |
5,044,359 | 2011-02-18T17:15:00.000 | 1 | 0 | 0 | 0 | python,nltk | 5,085,486 | 1 | false | 0 | 0 | It means that when you pass in the input vector, you can either pass in a numpy.array() or a nltk_contrib.unimelb.tacohn.SparseArrays.
I suggest you look at the package nltk_contrib.unimelb.tacohn to find the SparseArrays class. Then try to create your data with this class before passing it into nltk.cluster | 1 | 0 | 1 | I am quite new in Python.
I am trying to use the nltk.cluster package to apply a simple kMeans to a word-document matrix. While it works when the matrix is a list of numpy array-like objects, I wasn't able to make it work for a sparse matrix representation (such as csc_matrix, csr_matrix or lil_matrix).
All the inform... | nltk.cluster using a sparse representation | 0.197375 | 0 | 0 | 824 |
5,046,877 | 2011-02-18T21:38:00.000 | 1 | 0 | 1 | 0 | python,hash | 5,046,925 | 4 | true | 0 | 0 | Not a good idea. The general contract of hash code is that if Object A equals Object B, A.hashCode() equals B.hashCode(). With what you're proposing this wont hold.
You could try using
list length as the hash code
hash code of the first item in the list as the hashcode
sum of all hashcodes of all items as the hashcode... | 3 | 0 | 0 | I have a class that essentially wraps a list, and lists apparently can't have hash values. My idea was to generate a random number and store that as the hash value. | Is it a good idea to generate and store a random number as a hash value for my class? | 1.2 | 0 | 0 | 218 |
5,046,877 | 2011-02-18T21:38:00.000 | 1 | 0 | 1 | 0 | python,hash | 5,047,083 | 4 | false | 0 | 0 | As mentioned by others, a if 2 objects are considered "equal" then they must have the same hash value.
How you define equals for your class is up to you. If you only care about referential equality then you could generate a random number on __init__, but it better be the case that MyWrapper([1,2,3]) == MyWrapper([1... | 3 | 0 | 0 | I have a class that essentially wraps a list, and lists apparently can't have hash values. My idea was to generate a random number and store that as the hash value. | Is it a good idea to generate and store a random number as a hash value for my class? | 0.049958 | 0 | 0 | 218 |
5,046,877 | 2011-02-18T21:38:00.000 | 0 | 0 | 1 | 0 | python,hash | 5,047,119 | 4 | false | 0 | 0 | It is reasonable to support hashing for mutable containers - but the general rule is that you're hashing the current value, not the container.
EDIT That's reasonable in principle, though Python generally guards against it.
There's even a specific hashing technique for this kind of task. Zobrist hashing calculates a ha... | 3 | 0 | 0 | I have a class that essentially wraps a list, and lists apparently can't have hash values. My idea was to generate a random number and store that as the hash value. | Is it a good idea to generate and store a random number as a hash value for my class? | 0 | 0 | 0 | 218 |
5,046,903 | 2011-02-18T21:41:00.000 | 4 | 0 | 1 | 0 | python,class,types,language-features | 5,047,123 | 2 | false | 0 | 0 | Although I agree with Daniel DiPaolo that you should never need to use old-style classes in your code, there will be times when you will need to understand them a little bit.
For example, with old-style classes you can't use super to call a parent method - and this can bite you when you try and subclass, for example, t... | 1 | 5 | 0 | I am currently learning Python 2.6.5 and I found out about old style classes and new style classes.
I understand that these classes are still existing only for backward compatibility and that they are removed in Python 3.
So the question is this: as a newcomer to the language, do I need to learn about the classic clas... | Python - do I need to learn about old style classes? | 0.379949 | 0 | 0 | 427 |
5,048,436 | 2011-02-19T02:23:00.000 | 7 | 0 | 0 | 0 | python,google-chrome-extension | 9,693,740 | 7 | false | 1 | 0 | Although you mentioned you don't want it to be a hosted app, but this is one typical scenario where a hosted app can do.
SciPy is not a package that is easy to deploy. Even if you are writing a installed application based on SciPy, it requires some effort to deploy this dependency. A web application can help here wher... | 1 | 49 | 0 | I would like to create a google chrome extension. Specifically, I'd like to make a packaged app, but not a hosted app. Am I correct in thinking this limits me to JavaScript (and HTML/CSS)?
My problem is that I need to do some complex math (singular value decomposition, factor analysis) and I don't want to write algorit... | Chrome extension in python? | 1 | 0 | 1 | 65,662 |
5,048,515 | 2011-02-19T02:49:00.000 | 1 | 0 | 1 | 0 | python,process | 5,048,580 | 2 | false | 0 | 0 | You need to communicate using a shared resource. In the simplest sense, you use the resource as a mutex. Lock or pid files are commonly used this way on *nix by using the filesystem as that shared resource.
Depending on need, you can use a shared resource that allows communication; e.g. a web browser executed to open... | 1 | 5 | 0 | I need to add a function to my python script that checks if the current script is already running. If it is then it will quit, if not it continues running the script. I've looked into methods of doing this but I cant figure out how to do it. | Check if current process is running using Python? | 0.099668 | 0 | 0 | 5,538 |
5,049,244 | 2011-02-19T06:20:00.000 | 1 | 0 | 0 | 0 | python,response | 5,049,353 | 3 | false | 0 | 0 | Sorry but this does not make much sense and is likely a violation of the HTTP protocol. I consider such an idea as weird and broken-by-design. Either make the remote server shut up or configure your application or whatever is running on the remote server on a different protocol level using a smarter protocol with less ... | 2 | 3 | 0 | I am using a server to send some piece of information to another server every second. The problem is that the other server response is few kilobytes and this consumes the bandwidth on the first server ( about 2 GB in an hour ). I would like to send the request and ignore the return ( not even receive it to save bandwid... | How can i ignore server response to save bandwidth? | 0.066568 | 0 | 1 | 1,828 |
5,049,244 | 2011-02-19T06:20:00.000 | 2 | 0 | 0 | 0 | python,response | 5,049,588 | 3 | false | 0 | 0 | A 5K reply is small stuff and is probably below the standard TCP window size of your OS. This means that even if you close your network connection just after sending the request and checking just the very first bytes of the reply (to be sure that request has been really received) probably the server already sent you th... | 2 | 3 | 0 | I am using a server to send some piece of information to another server every second. The problem is that the other server response is few kilobytes and this consumes the bandwidth on the first server ( about 2 GB in an hour ). I would like to send the request and ignore the return ( not even receive it to save bandwid... | How can i ignore server response to save bandwidth? | 0.132549 | 0 | 1 | 1,828 |
5,049,842 | 2011-02-19T08:57:00.000 | 3 | 0 | 1 | 0 | python,autocomplete,pycharm | 9,671,230 | 10 | false | 0 | 0 | Try clicking "Reload" button in File | Settings | IDE Settings | Python interpreters. That got it working for me. | 3 | 29 | 0 | When writing Python code using compiled extensions (the OpenCV Python bindings, for example), PyCharm doesn't seem to be aware of their availability. The imports are marked with a grey underline, saying "unresolved reference" as a tooltip, and autocomplete doesn't work, either. (Except for the function names already us... | Autocomplete in PyCharm for Python compiled extensions | 0.059928 | 0 | 0 | 25,124 |
5,049,842 | 2011-02-19T08:57:00.000 | 0 | 0 | 1 | 0 | python,autocomplete,pycharm | 22,992,917 | 10 | false | 0 | 0 | In my case on OS X 10.8 and PyCharm 3, IDE was automatically picking different installations of Python. I noticed this in Eclipse Pydev, which picked up the one right one and worked as expected. It was not easy to notice the difference between the two:
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python... | 3 | 29 | 0 | When writing Python code using compiled extensions (the OpenCV Python bindings, for example), PyCharm doesn't seem to be aware of their availability. The imports are marked with a grey underline, saying "unresolved reference" as a tooltip, and autocomplete doesn't work, either. (Except for the function names already us... | Autocomplete in PyCharm for Python compiled extensions | 0 | 0 | 0 | 25,124 |
5,049,842 | 2011-02-19T08:57:00.000 | 0 | 0 | 1 | 0 | python,autocomplete,pycharm | 61,683,052 | 10 | false | 0 | 0 | After two days test,I finally fix this issue:
The difference:
Uninstall python 3.7.2,install python 3.7.7.
Change the path where python install.(I strongly doubt that the cause is that my PATH of opencv-python has some Chinese characters.It should have only English).
Then do:
Install the opencv-contrib-python. | 3 | 29 | 0 | When writing Python code using compiled extensions (the OpenCV Python bindings, for example), PyCharm doesn't seem to be aware of their availability. The imports are marked with a grey underline, saying "unresolved reference" as a tooltip, and autocomplete doesn't work, either. (Except for the function names already us... | Autocomplete in PyCharm for Python compiled extensions | 0 | 0 | 0 | 25,124 |
5,050,372 | 2011-02-19T10:57:00.000 | 0 | 1 | 1 | 0 | c++,python,boost,system | 5,055,236 | 1 | true | 0 | 1 | Can you give us a rough idea of how large the game is going to be?
If you're not careful, you could give yourself a lot of extra work without much benefit, but with some planning it sounds like it might help. The important questions are "What parts of the program do I want to simplify?", "Do I need a scripting language... | 1 | 1 | 0 | I'm developing a game and now I want to make script system for it.
Now I have abstract class Object which is inherited by all game objects. I have to write a lot of technical code, add new object type into enum, register parser function for each object (that function parses object's params from file).
I don't want to m... | Script system in application | 1.2 | 0 | 0 | 203 |
5,050,817 | 2011-02-19T12:40:00.000 | 0 | 0 | 0 | 0 | python,qt4,pyqt,pyqt4,qlistwidget | 18,070,801 | 2 | false | 0 | 1 | More than likely this functionality exists because the multitouch event is being interpreted by your operating system as a scroll of some type and QT is recieving the scroll action, rather than the multitouch action directly. | 1 | 3 | 0 | I'm having a problem with a simple Notepad application I'm writing to teach myself basic Python/PyQt.
Specifically, I want to know how to change the multi-touch pan gesture sensitivity on a QListWidget.
As it is now, when I drag up and down with 2 fingers, it seems like the list is moving up/down one step for each pix... | Customize PyQt multi-touch pan gestures on QListWidget | 0 | 0 | 0 | 1,586 |
5,051,151 | 2011-02-19T13:59:00.000 | 3 | 0 | 0 | 0 | python,sqlite,rollback | 5,051,345 | 1 | true | 0 | 0 | You can't both commit and rollback the same transaction. con1.commit() ends your transaction on that cursor. The next con1.rollback() is either being silently ignored or is rolling back an empty transaction. | 1 | 0 | 0 | Consider this test case:
import sqlite3
con1 = sqlite3.connect('test.sqlite')
con1.isolation_level = None
con2 = sqlite3.connect('test.sqlite')
con2.isolation_level = None
cur1 = con1.cursor()
cur2 = con2.cursor()
cur1.execute('CREATE TABLE foo (bar INTEGER, baz STRING)')
con1.isolation_level = 'IMMEDIATE'
cur1.execut... | Python sqlite3 module not rolling back transactions | 1.2 | 1 | 0 | 488 |
5,051,408 | 2011-02-19T14:42:00.000 | 2 | 0 | 0 | 0 | python,database,django,twisted | 5,051,832 | 2 | false | 1 | 0 | I would just avoid the Django ORM, it's not all that and it would be a pain to access outside of a Django context (witness the work that was required to make Django support multiple databases). Twisted database access always requires threads (even with twisted.adbapi), and threads give you access to any ORM you choose.... | 2 | 9 | 0 | I am developing a multiplayer gaming server that uses Django for the webserver (HTML frontend, user authentication, games available, leaderboard, etc.) and Twisted to handle connections between the players and the games and to interface with the games themselves. The gameserver, the webserver, and the database may run... | Sharing a database between Twisted and Django | 0.197375 | 1 | 0 | 2,454 |
5,051,408 | 2011-02-19T14:42:00.000 | 10 | 0 | 0 | 0 | python,database,django,twisted | 5,051,760 | 2 | true | 1 | 0 | First of all I'd identify why you need both Django and Twisted. Assuming you are comfortable with Twisted using twisted.web and auth will easily be sufficient and you'll be able to reuse your database layer for both the frontend and backend apps.
Alternatively you could look at it the other way, what is Twisted doing ... | 2 | 9 | 0 | I am developing a multiplayer gaming server that uses Django for the webserver (HTML frontend, user authentication, games available, leaderboard, etc.) and Twisted to handle connections between the players and the games and to interface with the games themselves. The gameserver, the webserver, and the database may run... | Sharing a database between Twisted and Django | 1.2 | 1 | 0 | 2,454 |
5,053,174 | 2011-02-19T20:00:00.000 | 8 | 0 | 1 | 0 | python,zope | 5,053,242 | 2 | true | 0 | 0 | zc is "Zope Corporation".
z3c is "Zope 3 community", a namespace that long since has been "deprecated", ie no new packages are made with this namespace.
collective refers to the Plone Collective, a svn repository for Plone packages with a friendly attitude towards contributors. It's been the "default" namespace for ne... | 2 | 6 | 0 | So they all are somehow related to zope. Question is how?
I am not familiar with Zope. I guess that zc, z3c stand for Zope Component and Zope3 Component but I want to be sure. Also there is a collective namespace. What kind of packages goes under it?
What are other well known python package namespaces?
Are there any co... | What is behind python package namespaces: z3c, zc, collective? | 1.2 | 0 | 0 | 330 |
5,053,174 | 2011-02-19T20:00:00.000 | 1 | 0 | 1 | 0 | python,zope | 6,144,491 | 2 | false | 0 | 0 | Stephan Richter and I where prototyping some packages on a zope sprint which didn't really fit into the zope package namespace. This was the time we started using z3c as a package name.
This should mean zope 3 community as Lennart says. But the namespace is not deprecated.
Probably the question is more which license co... | 2 | 6 | 0 | So they all are somehow related to zope. Question is how?
I am not familiar with Zope. I guess that zc, z3c stand for Zope Component and Zope3 Component but I want to be sure. Also there is a collective namespace. What kind of packages goes under it?
What are other well known python package namespaces?
Are there any co... | What is behind python package namespaces: z3c, zc, collective? | 0.099668 | 0 | 0 | 330 |
5,054,191 | 2011-02-19T23:24:00.000 | 4 | 0 | 0 | 1 | python,google-app-engine,import | 5,054,203 | 3 | true | 1 | 0 | You can read from the filesystem in GAE just fine; you just can't write to the filesystem.
from models import * will only import modules listed in __all__ in models/__init__.py; there's no automatic way to import all modules in a package if they're not declared to be part of the package. You just need to read the direc... | 1 | 0 | 0 | Let me explain the use case...
In a simple python web application framework designed for Google App Engine, I'd like to have my models loaded automatically from a 'models' directory, so all that's needed to add a model to the application is place a file user.py (for example), which contains a class called 'User', in th... | Is it possible to 'import * from DIRECTORY', then somehow (anyhow) iterate over the loaded modules? | 1.2 | 0 | 0 | 210 |
5,055,605 | 2011-02-20T06:21:00.000 | 2 | 0 | 0 | 0 | python,progress-bar,httplib2 | 5,055,776 | 2 | true | 0 | 0 | No. httplib2 doesn't have any kind of progress beacon callback, so it simply blocks until the request is finished. | 1 | 1 | 0 | Is it possible to display the percentage a file has downloaded in python while using httplib2? I know you can with urllib2 but I want to use httplib2. | httplib2 download progress bar in python | 1.2 | 0 | 1 | 687 |
5,056,064 | 2011-02-20T08:48:00.000 | 0 | 0 | 1 | 0 | python,list,element | 5,056,088 | 6 | false | 0 | 0 | If you're not worried about the order, d = list(set(d))). | 2 | 0 | 0 | Please help (I know that it's a silly question):
I have a list d = [' ABA', ' AAB', ' BAA', ' BAA', ' AAB', ' ABA']. How can I exclude elements that appear more than once? | element that appear more that once in the list in Python | 0 | 0 | 0 | 14,719 |
5,056,064 | 2011-02-20T08:48:00.000 | 0 | 0 | 1 | 0 | python,list,element | 5,056,086 | 6 | false | 0 | 0 | Lets say you got a list named Words and a list UniqueWords, start a loop on Words, on each iteration you check if the list UniqueWords contains the iterated element, if so then continue, if not then add it to the UniqueWords. In the end you will have a list without duplicates. Another way you could do is a loop in a l... | 2 | 0 | 0 | Please help (I know that it's a silly question):
I have a list d = [' ABA', ' AAB', ' BAA', ' BAA', ' AAB', ' ABA']. How can I exclude elements that appear more than once? | element that appear more that once in the list in Python | 0 | 0 | 0 | 14,719 |
5,057,399 | 2011-02-20T13:48:00.000 | 1 | 0 | 1 | 0 | excel,parsing,python-3.x | 5,057,741 | 3 | false | 0 | 0 | My suggestion would be to contact the authors of the libraries and help port them. It's not horribly hard and quite fun! Your only other option is to use Python 2, and that is obviously not as fun. :)
Possibly you could export to CSV as well, but I guess you would have if that was an option. | 1 | 7 | 0 | I have found very few libraries in Python able to parse excel files, and none of them were in Python 3.x nor passed with success the 2to3 step.
What would be your suggestions ? | Parsing Excel files with Python 3.x | 0.066568 | 0 | 0 | 7,688 |
5,057,923 | 2011-02-20T15:24:00.000 | 38 | 0 | 0 | 0 | python,copy-paste | 5,058,131 | 1 | true | 0 | 0 | Do you mean that you want to copy/paste source code/text in the Python command line?
If you're on Windows, it works just like any DOS console. I recommend you open your Python console, click on the left upper icon and select "Properties". Then, on the options tab, check the "Insert mode" and "Quick Edit mode" checkboxe... | 1 | 7 | 0 | Also, are there any functions I can use keyboard to control in order to create a program more efficiently?
Thanks | How to copy and paste by using Keyboard in python? | 1.2 | 0 | 0 | 70,626 |
5,058,333 | 2011-02-20T16:30:00.000 | 1 | 0 | 0 | 0 | python,google-app-engine | 17,245,724 | 2 | false | 1 | 0 | If you are presenting the survey question in a browser, I would definitely go with one model (in one datastore as noted by Peter) having questions and answers properties. Serialize the questions and answers into two TextProperties (be sure to escape them first). From this point, everything can be done inside Javascript... | 1 | 0 | 0 | Hey I am trying to create a survey that asks the users to create his own question and list 5 multiple choices. My first sense is that I create two datastores and one to store the user quesiton and one to to store 5 choices mapping to the question just created. but i dont know how exactly I should do with the 5 multipl... | how to create a survey that has 5 multiple choices | 0.099668 | 0 | 0 | 2,507 |
5,058,591 | 2011-02-20T17:16:00.000 | 1 | 0 | 0 | 0 | python,math,pygame | 5,058,696 | 2 | false | 0 | 1 | Try using polar coordinates. It's natural :)
If you don't calculate enough frames to make your orbit look smooth, calculate 3-4 intermediate points of orbit to draw shorter line segments, without calculating the game state at these points. Make this radius-dependent. This helps proper collision detection, too. | 1 | 1 | 0 | How can i make a smooth circular orbit at a constant speed using pygame?
How would i calculate x, y on a circle? | Making smooth orbits in pygame | 0.099668 | 0 | 0 | 907 |
5,058,768 | 2011-02-20T17:41:00.000 | 0 | 0 | 1 | 0 | python | 5,058,796 | 4 | false | 0 | 0 | You could try creating only a limited amount of workers and distribute work between them. Python's multiprocessing.Pool would be the thing to use. | 2 | 0 | 0 | guys!
My application is a bot. It simply receives a message, process it and returns result.
But there are a lot of messages and I'm creating separate thread for processing each, but it makes an application slower (not a bit).
So, Is it any way to reduce CPU usage by replacing threads with something else? | Threads in Python again | 0 | 0 | 0 | 252 |
5,058,768 | 2011-02-20T17:41:00.000 | 0 | 0 | 1 | 0 | python | 5,058,911 | 4 | false | 0 | 0 | You might not even need threads. If your server can handle each request quickly, you can just make it all single-threaded using something like Twisted. | 2 | 0 | 0 | guys!
My application is a bot. It simply receives a message, process it and returns result.
But there are a lot of messages and I'm creating separate thread for processing each, but it makes an application slower (not a bit).
So, Is it any way to reduce CPU usage by replacing threads with something else? | Threads in Python again | 0 | 0 | 0 | 252 |
5,059,567 | 2011-02-20T19:49:00.000 | 1 | 0 | 1 | 0 | documentation,python-3.x,documentation-generation | 5,059,933 | 1 | true | 0 | 0 | Apparently in Jinja, something is doing X.next(). In Python 3 that's next(x) instead. It should be a simple fix. | 1 | 3 | 0 | I recently felt the urge to generate documentation for my little project. I thought it would be fairly easy since I had a set of nice docstrings. Turns out the whole process is much more complicated in python 3.1.
Here's what I tried:
epydoc: Fails because it's for python 2. 2to3 didn't solve the problems
pydoc: I ca... | Documentation generator for python3 | 1.2 | 0 | 0 | 872 |
5,059,883 | 2011-02-20T20:43:00.000 | 2 | 0 | 0 | 0 | python,mysql,django | 5,412,380 | 1 | true | 1 | 0 | I found that the key was actually generated under HKEY_CURRENT_USER instead of HKEY_LOCAL_MACHINE. Thanks. | 1 | 5 | 0 | I am trying to MySQL for Python (MySQLdb package) in Windows so that I can use it in the Django web frame.
I have just installed MySQL Community Server 5.5.9 and I have managed to run it and test it using the testing procedures suggested in the MySQL 5.5 Reference Manual. However, I discovered that I still don't have t... | MySQL AB, MySQL Server 5.5 Folder in HKEY_LOCAL_MACHINE not present | 1.2 | 1 | 0 | 854 |
5,060,172 | 2011-02-20T21:29:00.000 | 3 | 0 | 1 | 0 | python | 5,060,411 | 2 | false | 0 | 0 | Yes, it will work, if you use self to invoke the method, or cls in a classmethod.
Nonetheless, I'd definitely advise using a classmethod instead. This will allow implentations to look at class attributes, and if you ever end up with multiple levels of inheritance it can make things easier on the intermediate classes t... | 1 | 8 | 0 | The question just about says it. I have an abstract class that calls a staticmethod in a helper function, and I want subclasses to simply define the staticmethod and run with it.
Maybe I could use something along the lines of getattr? Should I use a @classmethod instead? | Can @staticmethod's be inherited? | 0.291313 | 0 | 0 | 10,929 |
5,060,382 | 2011-02-20T22:02:00.000 | 0 | 0 | 0 | 0 | python,client-side | 5,060,400 | 5 | false | 1 | 0 | Short of writing your own browser plugin — no. | 3 | 1 | 0 | Is there any way to get Python to run on a web browser, other than silverlight?
I'm pretty sure not, but it never hurts to ask (usually). | web: client-side python? | 0 | 0 | 1 | 717 |
5,060,382 | 2011-02-20T22:02:00.000 | 2 | 0 | 0 | 0 | python,client-side | 5,060,425 | 5 | false | 1 | 0 | Haven't tried it myself but Pyjamas (http://pyjs.org/) claims to contain a Python-to-Javascript compiler. Not exactly what you're asking for but might be worth a look. | 3 | 1 | 0 | Is there any way to get Python to run on a web browser, other than silverlight?
I'm pretty sure not, but it never hurts to ask (usually). | web: client-side python? | 0.07983 | 0 | 1 | 717 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.