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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
6,755,995 | 2011-07-20T01:24:00.000 | 0 | 0 | 0 | 0 | python,openerp | 6,854,128 | 2 | false | 1 | 1 | are you trying to raise any kind of error message or you want to have confirmation ?
if you want to raise exception, then it's possible , check in the addons/account.py
you'll find something that you are looking for. | 1 | 0 | 0 | I have a button on a new form. When this button clicked I need a show some information on new form using label /or other component/. How to do it in OpenERP 6? I don't have any idea. Please give me a hand. thanks. | Dynamically create a message | 0 | 0 | 0 | 103 |
6,756,308 | 2011-07-20T02:22:00.000 | 5 | 0 | 0 | 0 | python,django,django-piston | 9,088,385 | 2 | false | 1 | 0 | In your settings.py file, add PISTON_DISPLAY_ERRORS = False this will cause exceptions to be raised allowing them to be shown as expected in the Django debug error page when you are using DEBUG = True.
There are a few cases when the exception won't propagate properly. I've seen it happen when Piston says that the funct... | 1 | 1 | 0 | I'm using Piston with Django. Anytime there's an error in my handler code, I get a simplified, text-only description of the error in my http response, which gives me much less information that Django does when it's reporting errors. How can I stop Piston catching errors in this way? | Stop Piston's error catching | 0.462117 | 0 | 0 | 174 |
6,756,630 | 2011-07-20T03:18:00.000 | 4 | 1 | 0 | 0 | python,messaging,mpi,rabbitmq,amqp | 6,757,194 | 2 | false | 0 | 0 | This is exactly the scenario I was in a few months ago and I decided to use AMQP with RabbitMQ using topic exchanges, in addition to memcache for large objects.
The AMQP messages are all strings, in JSON object format so that it is easy to add attributes to a message (like number of retries) and republish it. JSON obje... | 2 | 7 | 0 | Suppose that one is interested to write a python app where there should be communication between different processes. The communications will be done by sending strings and/or numpy arrays.
What are the considerations to prefer OpenMPI vs. a tool like RabbitMQ? | Python: OpenMPI Vs. RabbitMQ | 0.379949 | 0 | 0 | 4,063 |
6,756,630 | 2011-07-20T03:18:00.000 | 13 | 1 | 0 | 0 | python,messaging,mpi,rabbitmq,amqp | 6,756,939 | 2 | true | 0 | 0 | There is no single correct answer to such question. It all depends on a big number of different factors. For example:
What kind of communications do you have? Are you sending large packets or small packets, do you need good bandwidth or low latency?
What kind of delivery guarantees do you need?
OpenMPI can instantly d... | 2 | 7 | 0 | Suppose that one is interested to write a python app where there should be communication between different processes. The communications will be done by sending strings and/or numpy arrays.
What are the considerations to prefer OpenMPI vs. a tool like RabbitMQ? | Python: OpenMPI Vs. RabbitMQ | 1.2 | 0 | 0 | 4,063 |
6,759,115 | 2011-07-20T08:34:00.000 | 5 | 0 | 0 | 1 | python,asynchronous,twisted,wsgi | 6,761,019 | 2 | true | 1 | 0 | Why do you want to use WSGI and do asynchronous things? The benefit of WSGI is that you can deploy your application on any WSGI container. If you start using Twisted APIs to do asynchronous things, then you can only deploy your application in Twisted's WSGI container.
You should probably just use Twisted Web without ... | 2 | 8 | 0 | I'm building a web interface for a twisted application and would like to use WSGI rather than twisted.web directly (since the rest of the website is WSGI and I already have a substantial WSGI codebase).
The Twisted documentation page I found about WSGIResource (http://twistedmatrix.com/documents/current/web/howto/web-i... | Asynchronous WSGI with Twisted | 1.2 | 0 | 0 | 3,732 |
6,759,115 | 2011-07-20T08:34:00.000 | 5 | 0 | 0 | 1 | python,asynchronous,twisted,wsgi | 7,313,910 | 2 | false | 1 | 0 | In principle, WSGI is not intrinsically incompatible with asynchronous program design; in fact, PEP 333 goes to some considerable length to specify how servers, applications and middleware must behave to support that kind of thing.
At the heart of this is returning an iterator to the container. Every time an asynchron... | 2 | 8 | 0 | I'm building a web interface for a twisted application and would like to use WSGI rather than twisted.web directly (since the rest of the website is WSGI and I already have a substantial WSGI codebase).
The Twisted documentation page I found about WSGIResource (http://twistedmatrix.com/documents/current/web/howto/web-i... | Asynchronous WSGI with Twisted | 0.462117 | 0 | 0 | 3,732 |
6,759,459 | 2011-07-20T09:06:00.000 | 2 | 0 | 1 | 0 | python,image,python-imaging-library,layer,psd | 7,392,375 | 5 | false | 0 | 0 | You can use the win32com for accessing the Photoshop with Python.
Possible pseudo code for your work:
Load the PSD file
Collect all layers and make all layers VISIBLE=OFF
Turn one layer after another, mark them VISIBLE=ON and export to PNG
import win32com.client
pApp = win32com.client.Dispatch('Photoshop.... | 1 | 6 | 0 | I need to write a Python program for loading a PSD photoshop image, which has multiple layers and spit out png files (one for each layer).
Can you do that in Python? I've tried PIL, but there doesn't seem to be any method for accessing layers. Help.
PS. Writing my own PSD loader and png writer has shown to be way too s... | Python PSD layers? | 0.07983 | 0 | 0 | 14,621 |
6,760,380 | 2011-07-20T10:22:00.000 | 7 | 0 | 0 | 0 | python,matrix | 6,760,471 | 2 | true | 0 | 0 | Just use a tuple or list.
A tuple matrices = tuple(matrix1, matrix2, matrix3) will be slightly more efficient;
A list matrices = [matrix1, matrix2, matrix3] is more flexible as you can matrix.append(matrix4).
Either way you can access them as matrices[0] or for matrix in matricies: pass # do stuff. | 2 | 2 | 1 | In Matlab, there is something called struct, which allow the user to have a dynamic set of matrices.
I'm basically looking for a function that allows me to index over dynamic matrices that have different sizes.
Example: (with 3 matrices)
Matrix 1: 3x2
Matrix 2: 2x2
Matrix 3: 2x1
Basically I want to store the 3 matr... | N-Dimensional Matrix Array in Python (with different sizes) | 1.2 | 0 | 0 | 4,483 |
6,760,380 | 2011-07-20T10:22:00.000 | 0 | 0 | 0 | 0 | python,matrix | 6,760,481 | 2 | false | 0 | 0 | Put those arrays into a list. | 2 | 2 | 1 | In Matlab, there is something called struct, which allow the user to have a dynamic set of matrices.
I'm basically looking for a function that allows me to index over dynamic matrices that have different sizes.
Example: (with 3 matrices)
Matrix 1: 3x2
Matrix 2: 2x2
Matrix 3: 2x1
Basically I want to store the 3 matr... | N-Dimensional Matrix Array in Python (with different sizes) | 0 | 0 | 0 | 4,483 |
6,761,201 | 2011-07-20T11:33:00.000 | 0 | 1 | 0 | 0 | python,module,licensing | 6,761,407 | 1 | true | 0 | 0 | You need to pay a copyright lawyer to tell you that. But my guess is that you need to use the PSF license. Note that PSF does not have the copyright to Python source code. They coders do how that copyright translates into you making a C# port is something only a copyright expert can say. Also note that it is likely to ... | 1 | 1 | 1 | I have ported python3 csv module to C# what license could I use for my module?
Should I distribute my module?
Should I put PSF copyright in every header of my module?
thanks | Ported python3 csv module to C# what license should I use for my module? | 1.2 | 0 | 0 | 122 |
6,761,898 | 2011-07-20T12:30:00.000 | 2 | 1 | 0 | 0 | python,random,unique,uniqueidentifier | 6,762,089 | 5 | false | 0 | 0 | How about something like Amazon's payphrases? Convert the binary ID to a sequence of english words.
If you want something with the same range as a UUID, you need to represent 16 bytes.
To keep it reasonable, restrict the phrase to 4 words, so each word represents 4 bytes, or 65536 possibilities, so you'll need a dictio... | 1 | 17 | 0 | How do I generate a unique ID value that can be easily passed on via phone or email, that can be easily remembered while still not being easily guessable.
I am using database. But as I am giving away the ID to people I do not want it to be bound to a database. I could do something with the unique ID I already have in d... | How to generate a human friendly unique ID in Python? | 0.07983 | 0 | 0 | 14,441 |
6,764,063 | 2011-07-20T15:05:00.000 | 0 | 0 | 1 | 0 | python,performance,algorithm,list | 6,764,139 | 8 | false | 0 | 0 | You probably want to use a Set if you're worried about time. A Set is much like a list, but it checks for membership based on hashing. | 2 | 3 | 0 | I'm wondering because I need to have have a function that is disgustingly fast at checking if a word is in a dictionary list - I'm considering leaving the dictionary as a large string and running regex against instead. This needs to be absurdly fast. So I just need a basic overview of how python handles checking if a s... | How does Python handle checking 'if object in list' | 0 | 0 | 0 | 271 |
6,764,063 | 2011-07-20T15:05:00.000 | 0 | 0 | 1 | 0 | python,performance,algorithm,list | 6,764,236 | 8 | false | 0 | 0 | Use a set.
If you need case-insensitive checking, just store the words into the set downcased. Then when checking if a certain word is in the set, downcase the word before checking membership.
The general rule is: normalize entries when building the set, and normalize an item before checking against the set. Another ex... | 2 | 3 | 0 | I'm wondering because I need to have have a function that is disgustingly fast at checking if a word is in a dictionary list - I'm considering leaving the dictionary as a large string and running regex against instead. This needs to be absurdly fast. So I just need a basic overview of how python handles checking if a s... | How does Python handle checking 'if object in list' | 0 | 0 | 0 | 271 |
6,764,217 | 2011-07-20T15:13:00.000 | 0 | 0 | 0 | 0 | python,multithreading,user-interface,consumer,producer | 6,766,383 | 1 | true | 0 | 1 | Have your thread set a flag when it is done. Have the GUI periodically check for that flag and dismiss the window when it is set.
You can check for the flag by creating a function that checks for the flag, and if it's not set it uses after to have itself run again a few hundred ms later. The window won't go away immedi... | 1 | 0 | 0 | I have a Python GUI that uses Tkinter. I have to SSH into another place to get data. I start a new thread to do this so that the GUI doesn't hang. During this time, I want to pop up a screen that lets the user know it is loading. Once the program is finished getting the data, I want to close the loading screen. What mu... | How do I close a loading screen right when the other thread is finished in Python using Tk? | 1.2 | 0 | 0 | 163 |
6,764,329 | 2011-07-20T15:21:00.000 | 8 | 0 | 0 | 0 | python,optimization,pyqt | 6,821,582 | 2 | true | 0 | 1 | I'm not sure if this is exactly the same thing you are doing, but it sounds similar to something I have in some apps, where there is some list of custom widget. And it does significantly slow down when you are creating and destroying tons of widgets.
If its an issue of lesser amounts of total widgets, but just being cr... | 2 | 6 | 0 | For those of you who have written fairly complex PyQt applications, what tips and tricks would you offer for speeding up your applications? I have a few examples of where my program begins to slow down as it grows larger:
I have a 'dashboard' written that is destroyed and re-created when a user clicks on an item in a ... | Optimizing your PyQt applications | 1.2 | 0 | 0 | 3,849 |
6,764,329 | 2011-07-20T15:21:00.000 | 1 | 0 | 0 | 0 | python,optimization,pyqt | 6,774,281 | 2 | false | 0 | 1 | Are you using QNetworkAccessManager to load you images? It has cache support. Also it loads everything in background with finishing callbacks.
I don't really understand what your dashboard is doing. Have you think about using QWebkit? Maybe your dashboard content is easy to be implemented in HTML?
PS. I don't like thre... | 2 | 6 | 0 | For those of you who have written fairly complex PyQt applications, what tips and tricks would you offer for speeding up your applications? I have a few examples of where my program begins to slow down as it grows larger:
I have a 'dashboard' written that is destroyed and re-created when a user clicks on an item in a ... | Optimizing your PyQt applications | 0.099668 | 0 | 0 | 3,849 |
6,765,619 | 2011-07-20T17:00:00.000 | 0 | 0 | 1 | 0 | python,datetime,date | 6,765,821 | 3 | false | 0 | 0 | I don't know whether there are libraries available (if there are, I'm sure they can be found in Django source code - it sounds like the kind of problems they must have thought of).
However, I don't find the problem too difficult in principle. You first define your boundaries. For example:
If it happened within one da... | 1 | 2 | 0 | Is there a way to go from
"1 day ago", "1 week ago", "3 hours ago"
to some date format like "Tue, 19 Jul 2011 10:00:00" using Python? | Reverse pretty date format | 0 | 0 | 0 | 382 |
6,766,199 | 2011-07-20T17:49:00.000 | 6 | 0 | 0 | 1 | python,google-app-engine,csv | 6,766,276 | 2 | false | 1 | 0 | Pass a StringIO object as the first parameter to csv.writer; then set the content-type and content-disposition on the response appropriately (probably "text/csv" and "attachment", respectively) and send the StringIO as the content. | 1 | 2 | 0 | I use python Appengine. I'm trying to create a link on a webpage, which a user can click to download a csv file. How can I do this?
I've looked at csv module, but it seems to want to open a file on the server, but appengine doesn't allow that.
I've looked at remote_api, but it seems that its only for uploading or down... | how to create a downloadable csv file in appengine | 1 | 0 | 0 | 1,482 |
6,767,283 | 2011-07-20T19:19:00.000 | 2 | 0 | 1 | 1 | python | 60,735,048 | 11 | false | 0 | 0 | First search for PYTHON IDLE from search bar
Open the IDLE and use below commands.
import sys
print(sys.path)
It will give you the path where the python.exe is installed. For eg:
C:\Users\\...\python.exe
Add the same path to system environment variable. | 3 | 207 | 0 | Python is on my machine, I just don't know where, if I type python in terminal it will open Python 2.6.4, this isn't in it's default directory, there surely is a way of finding it's install location from here? | Find where python is installed (if it isn't default dir) | 0.036348 | 0 | 0 | 480,351 |
6,767,283 | 2011-07-20T19:19:00.000 | 1 | 0 | 1 | 1 | python | 57,471,464 | 11 | false | 0 | 0 | On windows search python,then right click and click on "Open file location".That's how I did | 3 | 207 | 0 | Python is on my machine, I just don't know where, if I type python in terminal it will open Python 2.6.4, this isn't in it's default directory, there surely is a way of finding it's install location from here? | Find where python is installed (if it isn't default dir) | 0.01818 | 0 | 0 | 480,351 |
6,767,283 | 2011-07-20T19:19:00.000 | 43 | 0 | 1 | 1 | python | 44,020,984 | 11 | false | 0 | 0 | For Windows CMD run: where python
For Windows PowerShell run: Get-Command python | 3 | 207 | 0 | Python is on my machine, I just don't know where, if I type python in terminal it will open Python 2.6.4, this isn't in it's default directory, there surely is a way of finding it's install location from here? | Find where python is installed (if it isn't default dir) | 1 | 0 | 0 | 480,351 |
6,767,770 | 2011-07-20T20:01:00.000 | 9 | 0 | 0 | 0 | python,nlp,nltk | 6,767,866 | 1 | false | 0 | 0 | By "normalize" do you just mean making everything lowercase?
The decision about whether to lowercase everything is really dependent of what you plan to do. For some purposes, lowercasing everything is better because it lowers the sparsity of the data (uppercase words are rarer and might confuse the system unless you... | 1 | 6 | 1 | I've finished gathering my data I plan to use for my corpus, but I'm a bit confused about whether I should normalize the text. I plan to tag & chunk the corpus in the future. Some of NLTK's corpora are all lower case and others aren't.
Can anyone shed some light on this subject, please? | NLTK - when to normalize the text? | 1 | 0 | 0 | 2,668 |
6,769,405 | 2011-07-20T22:41:00.000 | 3 | 0 | 0 | 1 | python,linux,web-services,tcp,network-programming | 6,770,063 | 1 | false | 1 | 0 | To avoid this, have multiple application servers behind a load balancer. Before bringing one down, ensure the load balancer is not sending it new clients. Bring it down, traffic will go to the other applications servers, and when it comes back up traffic will begin getting sent to it again.
If you have only one applica... | 1 | 2 | 0 | A typical situation with a server/web application is that the application needs to be shut down and restarted to implement an upgrade.
What are the possible/common schemes (and available software) to avoid losing data that clients sent to the server during the short time the application was gone?
An example scheme that... | How to avoid packet loss on server application restart? | 0.53705 | 0 | 0 | 335 |
6,770,610 | 2011-07-21T02:12:00.000 | 1 | 1 | 0 | 0 | python,encryption,credentials | 6,770,811 | 2 | false | 0 | 0 | An alternative to DRM (which is what you are describing) is to proxy the secured interaction through a server application on your own, controlled machine. Since you're using OAuth, you can use the same authentication credentials against your own server as you would connecting directly to twitter.
The advantage to this... | 1 | 0 | 0 | I'm writing an application that connects to twitter and uses the OAuth API, my issue is with storing the consumer_key and the consumer_key_secret
How can I safely store these values so they're difficult for the user to get to but still have ability to use them within my application?
I've had storing them within a pyc a... | A way to store sensitive data to disk, without (serious) fear of user tampering? | 0.099668 | 0 | 0 | 167 |
6,773,287 | 2011-07-21T08:33:00.000 | 2 | 0 | 1 | 0 | python,coding-style,pylint | 6,773,398 | 3 | false | 0 | 0 | It's almost impossible to use static analysis to verify that the arguments generated by ** are all valid, but if it is the only appropriate mechanism them by all means do use it. | 2 | 7 | 0 | I'm working on my first project using Python 2.7. We're coming from a Java background and our first instinct was to write python code in a Java-esque way. But now we're trying to adapt as much as possible. So far we are using pylint to adapt our code.
Now I keep running into a situation with pylint. Every time I use s... | python styling ** question | 0.132549 | 0 | 0 | 259 |
6,773,287 | 2011-07-21T08:33:00.000 | 2 | 0 | 1 | 0 | python,coding-style,pylint | 6,773,428 | 3 | false | 0 | 0 | ** excellent for what it is designed for: to forward arguments to other functions. You can definitely do bad things that will decrease the readability of your code with it, but it's not considered bad practice per se. | 2 | 7 | 0 | I'm working on my first project using Python 2.7. We're coming from a Java background and our first instinct was to write python code in a Java-esque way. But now we're trying to adapt as much as possible. So far we are using pylint to adapt our code.
Now I keep running into a situation with pylint. Every time I use s... | python styling ** question | 0.132549 | 0 | 0 | 259 |
6,774,561 | 2011-07-21T10:21:00.000 | 1 | 0 | 1 | 0 | python,multithreading,performance,benchmarking | 6,775,475 | 4 | false | 0 | 0 | I wonder, if there is any guidelines / benchmarks / advices which can help me to estimate ideal number of child process ?
No.
having one process per core is better than launching few hundreds of them?
You can never know in advance.
There are too many degrees of freedom.
You can only discover it empirically by run... | 3 | 2 | 0 | I have a python code treating a lot of apache logs (decompress, parse, crunching numbers, regexping etc). One parent process which takes a list of files (up to few millions), and sends a list of files to parse to workers, using multiprocess pool.
I wonder, if there is any guidelines / benchmarks / advices which can he... | Defining appropriate number of processes | 0.049958 | 0 | 0 | 429 |
6,774,561 | 2011-07-21T10:21:00.000 | 1 | 0 | 1 | 0 | python,multithreading,performance,benchmarking | 6,776,959 | 4 | false | 0 | 0 | Multiple cores do not provide better performance if the program is I/O bound. The performance might even become worse if the disk is serving two or more masters. | 3 | 2 | 0 | I have a python code treating a lot of apache logs (decompress, parse, crunching numbers, regexping etc). One parent process which takes a list of files (up to few millions), and sends a list of files to parse to workers, using multiprocess pool.
I wonder, if there is any guidelines / benchmarks / advices which can he... | Defining appropriate number of processes | 0.049958 | 0 | 0 | 429 |
6,774,561 | 2011-07-21T10:21:00.000 | 0 | 0 | 1 | 0 | python,multithreading,performance,benchmarking | 6,777,916 | 4 | false | 0 | 0 | I'm not sure if current OSes do this, but it used to be that I/O buffers were allocated per-process, so dividing one process' buffer among multiple threads would lead to buffer thrashing. You're far better off using multiple processes for I/O-heavy tasks. | 3 | 2 | 0 | I have a python code treating a lot of apache logs (decompress, parse, crunching numbers, regexping etc). One parent process which takes a list of files (up to few millions), and sends a list of files to parse to workers, using multiprocess pool.
I wonder, if there is any guidelines / benchmarks / advices which can he... | Defining appropriate number of processes | 0 | 0 | 0 | 429 |
6,775,359 | 2011-07-21T11:34:00.000 | 0 | 0 | 0 | 0 | python,django,database-permissions,django-permissions | 7,011,483 | 1 | true | 1 | 0 | I decided to go with manually checking the permissions, caching it whenever I can. I ended up with get_perms_from_cache(self, user) model method which helps me a lot. | 1 | 1 | 0 | I am developing a Django app being a Web frontend to some Oracle database with another local DB keeping app's data such as Guardian permissions. The problem is that it can be modified from different places that I don't have control of.
Let's say we have 3 models: User, Thesis and UserThesis.
UserThesis - a table specif... | Django-guardian on DB with shared (non-exclusive) access | 1.2 | 1 | 0 | 159 |
6,776,554 | 2011-07-21T13:09:00.000 | 2 | 0 | 1 | 0 | python | 6,776,649 | 4 | false | 0 | 0 | os.path.getsize(path) can give you the filesize of the file, but having two files the same size does not always mean they are identical. You could read the content of the file and have an MD5 or Hash of it to compare against. | 1 | 3 | 0 | I am using os.walk to compare two folders, and see if they contain the exact same files. However, this only checks the file names. I want to ensure the file sizes are the same, and if they're different report back. Can you get the file size from os.walk? | Get file size during os.walk | 0.099668 | 0 | 0 | 11,001 |
6,778,638 | 2011-07-21T15:30:00.000 | 0 | 0 | 0 | 0 | python,django,python-2.7 | 39,829,247 | 3 | false | 1 | 0 | **
[Errno 10013]
**
that error comes when the port you want to use is already in use by the another program.
so what you do just choose for another port which of which you can use port 8080
use the following commond
python manage.py runserver 8080 | 2 | 6 | 0 | I am having some problems running django. When I use the command manage.py runserver I receive an error that says: Error: [Errno 10013] An attempt was made to access a socket in a way forbidden by access permissions
I use postgreSQL as my database.
Edit: I run Windows Vista | manage.py runserver Error: [Errno 10013] | 0 | 0 | 0 | 18,673 |
6,778,638 | 2011-07-21T15:30:00.000 | 22 | 0 | 0 | 0 | python,django,python-2.7 | 6,778,708 | 3 | true | 1 | 0 | If you don't have permission to bind to a socket, you can try sudo manage.py runserver to do it with root privileges.
With Windows Vista / 7 you need to run the shell with administrator privileges. You can right click on the icon and select "Run as administrator" or go to c:\windows\system32\ and right click on cmd.ex... | 2 | 6 | 0 | I am having some problems running django. When I use the command manage.py runserver I receive an error that says: Error: [Errno 10013] An attempt was made to access a socket in a way forbidden by access permissions
I use postgreSQL as my database.
Edit: I run Windows Vista | manage.py runserver Error: [Errno 10013] | 1.2 | 0 | 0 | 18,673 |
6,780,827 | 2011-07-21T18:26:00.000 | 2 | 0 | 0 | 0 | python,django | 6,782,234 | 2 | true | 1 | 0 | rereading the file is a heavy penalty to pay when it's unlikely that the file has changed.
My usual approach is to use INotify to watch for configuration file changes, rather than trying to read a file on every request. Additionally, I tend to keep a "current" configuration, parsed from the file, and only replace it w... | 2 | 1 | 0 | I'm building a centralised django application that will be interacting with a dynamic number of databases with basically identical schema. These dbs are also used by a couple legacy applications, some of which are in PHP. Our solution to avoid multiple silos of db credentials is to store this info in generic setting ... | Dynamic per-request database connections in Django | 1.2 | 1 | 0 | 1,027 |
6,780,827 | 2011-07-21T18:26:00.000 | 0 | 0 | 0 | 0 | python,django | 6,780,942 | 2 | false | 1 | 0 | You could start different instances with different settings.py files (by setting different DJANGO_SETTINGS_MODULE) on different ports, and redirect the requests to the specific apps. Just my 2 cents. | 2 | 1 | 0 | I'm building a centralised django application that will be interacting with a dynamic number of databases with basically identical schema. These dbs are also used by a couple legacy applications, some of which are in PHP. Our solution to avoid multiple silos of db credentials is to store this info in generic setting ... | Dynamic per-request database connections in Django | 0 | 1 | 0 | 1,027 |
6,781,595 | 2011-07-21T19:26:00.000 | 0 | 0 | 0 | 0 | python,django,django-models | 9,685,570 | 2 | false | 1 | 0 | I would suggest to create a new model (let's say UserActions) in which you will trace all desired actions by adding an item on each of your others models "save" action.
Then you can easily build a view for this model and generate a feed with all the actions in chronological order. | 1 | 1 | 0 | I've a Django application that uses a Product model and a Comment model.
A User can add a Product to its favorite products list.
A User can leave a Comment to a Product.
I would implement a news feed in the home of my application, something like Facebook News feed.
Something like this:
user_1 just comments product_3... | Implement a feed stream in Django | 0 | 0 | 0 | 374 |
6,782,775 | 2011-07-21T21:05:00.000 | 0 | 0 | 1 | 1 | python,file-io,python-idle | 6,783,526 | 4 | false | 0 | 0 | Rest assured, python has no limitation in this regard. About the only two possibilities are:
There is a hard-to-see typo in your code so you are looking for the wrong file, or
The code is correct and the file really doesn't exist because there is a hard-to-see typo in the actual file name. For example, maybe the file ... | 1 | 2 | 0 | I have WORDS_TXT = /macintosh HD/users/[username]/Desktop/[file]/words.txt/
but when run, python says "no such file or directory", however going though finder and "go to folder" that exact pathname brings me to the file I am trying to open. I am running python 3.2 on a macbook pro with Mac OS X 10.7
thank you in advanc... | opening files using python / IDLE returns "no such file or directory" for pathname | 0 | 0 | 0 | 9,743 |
6,783,000 | 2011-07-21T21:25:00.000 | 0 | 0 | 1 | 0 | python,max | 6,783,187 | 5 | false | 0 | 0 | For Python 2 versions, IMO, I believe you cannot assume that max() returns the first maximal element in the list in the case of ties. I have this belief because max() is supposed to implement the true mathematical function max, which is used on sets that have a total order, and where elements do not have any "hidden in... | 1 | 76 | 0 | When using the max() function in Python to find the maximum value in a list (or tuple, dict etc.) and there is a tie for maximum value, which one does Python pick? Is it random?
This is relevant if, for instance, one has a list of tuples and one selects a maximum (using a key=) based on the first element of the tuple b... | Which maximum does Python pick in the case of a tie? | 0 | 0 | 0 | 38,578 |
6,784,748 | 2011-07-22T01:24:00.000 | 1 | 0 | 1 | 0 | python,nltk,stop-words | 6,794,673 | 2 | false | 0 | 0 | Take a look at other tagged corpora, like brown, for output examples. This will give you an idea of what a tagged corpus should look like. Next, load your corpus (with the PlaintextCorpusReader) and iterate over the sentences, tagging each sentence. Then write each tagged sentence to a file by making a string from the ... | 2 | 2 | 0 | I have a plaintext corpora, that I want to tag and save, so I can use it further. What's the best way to do this?
I already have my tagger made, but I can't figure out a way to change the corpora that isn't messy | Converting untagged corpora to tagged (NLTK) | 0.099668 | 0 | 0 | 671 |
6,784,748 | 2011-07-22T01:24:00.000 | 0 | 0 | 1 | 0 | python,nltk,stop-words | 6,785,644 | 2 | false | 0 | 0 | Are you doing simple unigram tagging, or are you actually parsing the text? I believe NLTK parses/tags such that the output of every token is (token, PoS). Is an array of tuples unacceptable for storing your corpora? Why do you find this messy? | 2 | 2 | 0 | I have a plaintext corpora, that I want to tag and save, so I can use it further. What's the best way to do this?
I already have my tagger made, but I can't figure out a way to change the corpora that isn't messy | Converting untagged corpora to tagged (NLTK) | 0 | 0 | 0 | 671 |
6,786,693 | 2011-07-22T07:03:00.000 | 0 | 0 | 0 | 1 | python,linux,desktop,gnu | 6,786,717 | 2 | false | 0 | 0 | No, Python is not pre-installed neither installed on every Linux distro. | 2 | 6 | 0 | I would like to know if is Python on every G/L distribution preinstalled or not. And why is it so popular on GNU/Linux and not so much on Windows? | Is Python on every GNU/Linux distribution? | 0 | 0 | 0 | 5,337 |
6,786,693 | 2011-07-22T07:03:00.000 | 7 | 0 | 0 | 1 | python,linux,desktop,gnu | 6,786,804 | 2 | true | 0 | 0 | Well python does not come on ALL GNU/Linux distros but is present on most of the popular Linux home user distributions (Ubuntu and Fedora Core for example), possibly because most of the application of Gnome desktop environment and KDE use python 2.5+ (not python 3 yet) interpreters. Since python is almost integrated on... | 2 | 6 | 0 | I would like to know if is Python on every G/L distribution preinstalled or not. And why is it so popular on GNU/Linux and not so much on Windows? | Is Python on every GNU/Linux distribution? | 1.2 | 0 | 0 | 5,337 |
6,787,345 | 2011-07-22T08:20:00.000 | 4 | 0 | 0 | 0 | python,nlp,nltk | 6,787,446 | 1 | false | 0 | 0 | In the general case, this is a very hard open research question. However, you might be able to get away with a simple solution a long as your "facts" follow a pretty simple grammar.
You could write a fairly simple solution by creating a set of transformation rules that act on parse trees. So if you saw a structure ... | 1 | 0 | 1 | The goal of this application is produce a system that can generate quizzes automatically. The user should be able to supply any word or phrase they like (e.g. "Sachin Tendulkar"); the system will then look for suitable topics online, identify a range of interesting facts, and rephrase them as quiz questions.
If I have ... | Quiz Generator using NLTK/Python | 0.664037 | 0 | 0 | 1,334 |
6,788,937 | 2011-07-22T10:51:00.000 | 0 | 0 | 0 | 0 | python,windows-7,oracle10g | 6,788,993 | 5 | false | 0 | 0 | It's not finding the module.
Things to investigate: Do you have several python installations? Did it go to the right one? Do a global search for cx_oracle and see if it's in the correct place. Check your PYTHONPATH variable. Check Python's registry values HKLM\Software\Python\Pyhoncore. Are they correct? | 3 | 3 | 0 | I use Windows 7 64 bit and Oracle 10g. I have installed python-2.7.2.amd64 and cx_Oracle-5.1-10g.win-amd64-py2.7.
When I importing cx_Oracle module I get this error:
Traceback (most recent call last):
File "C:\Osebno\test.py", line 1, in
import cx_oracle
ImportError: No module named cx_oracle
Can someone please ... | Error when importing cx_Oracle module [Python] | 0 | 1 | 0 | 17,773 |
6,788,937 | 2011-07-22T10:51:00.000 | 4 | 0 | 0 | 0 | python,windows-7,oracle10g | 6,789,312 | 5 | false | 0 | 0 | Have you tried import cx_Oracle (upper-case O) instead of import cx_oracle? | 3 | 3 | 0 | I use Windows 7 64 bit and Oracle 10g. I have installed python-2.7.2.amd64 and cx_Oracle-5.1-10g.win-amd64-py2.7.
When I importing cx_Oracle module I get this error:
Traceback (most recent call last):
File "C:\Osebno\test.py", line 1, in
import cx_oracle
ImportError: No module named cx_oracle
Can someone please ... | Error when importing cx_Oracle module [Python] | 0.158649 | 1 | 0 | 17,773 |
6,788,937 | 2011-07-22T10:51:00.000 | 1 | 0 | 0 | 0 | python,windows-7,oracle10g | 16,885,226 | 5 | false | 0 | 0 | after installing the cx_Oracle download the instant client form oracle owth all DLLs , then copy then in the same directory of cx_Oracle.pyd , it will work directly
tried and worked for me. | 3 | 3 | 0 | I use Windows 7 64 bit and Oracle 10g. I have installed python-2.7.2.amd64 and cx_Oracle-5.1-10g.win-amd64-py2.7.
When I importing cx_Oracle module I get this error:
Traceback (most recent call last):
File "C:\Osebno\test.py", line 1, in
import cx_oracle
ImportError: No module named cx_oracle
Can someone please ... | Error when importing cx_Oracle module [Python] | 0.039979 | 1 | 0 | 17,773 |
6,789,562 | 2011-07-22T11:50:00.000 | 1 | 0 | 1 | 0 | python,mongodb,pymongo | 6,789,704 | 2 | false | 0 | 0 | Sure, simply create a script that iterates over your current collection, reads the existing value and overwrite it with the new value (an embedded document in your case). You change the typ of the field by simply setting a new value for that field. E.g. setting a string field to an integer field :
db.test.update({field... | 1 | 2 | 0 | The type of a field in a collection in my mongodb database is unicode string. This field currently does not have any data associated with it in any of the documents in the collection.
I dont want the type to be string because,i want to add subfields to it from my python code using pymongo.
The collection already has ma... | Changing the type of a field in a collection in a mongodb database | 0.099668 | 1 | 0 | 1,765 |
6,789,757 | 2011-07-22T12:07:00.000 | 1 | 0 | 1 | 1 | python,installation,beautifulsoup | 6,789,804 | 2 | false | 1 | 0 | Set your PYTHONPATH environmental variable to point to the installation you want to install it for, and make sure you're using that version of Python when you run python setup.py install. Something like PYTHONPATH=/usr/lib/python25 /usr/bin/python25 setup.py install. | 1 | 1 | 0 | I have three versions of Python on my Mac: 2.6.1 (built-in), 2.5.4 (Google App Engine development), and 2.7.2 (general Python programming).
I installed BeautifulSoup with python setup.py install. However, only 2.7.2 is able to work with it.
How do I install it for 2.5.4 as well? | Install BeautifulSoup for another Python version on Mac OS X | 0.099668 | 0 | 0 | 739 |
6,789,927 | 2011-07-22T12:19:00.000 | 0 | 0 | 1 | 0 | python | 54,477,485 | 6 | false | 0 | 0 | You can also add constrains (upper bound and lower bound) on x with lsq_linear:
scipy.optimize.lsq_linear | 1 | 47 | 0 | I want to solve a linear equation with three or more variables. Is there a good library in python to do it? | Is there a python module to solve linear equations? | 0 | 0 | 0 | 76,437 |
6,791,799 | 2011-07-22T14:50:00.000 | 2 | 1 | 0 | 0 | javascript,php,python,mysql,serial-port | 9,482,670 | 2 | false | 1 | 0 | It seems there's a lot of places for things to go wrong.
Why not just cut out PHP all together and use python?
e.g. Use a python web framework & let your JavaScript communicate with that and while also reading the serial port and logging to MySQL.
That's just me though. I'd try and cut out as many points where it could... | 2 | 1 | 0 | Wanted to get some feedback on this implementation.
I'm developing an application on the PC to send and receive data to the serial port.
Some of the data received by the application will be solicited, while other data unsolicited.
Controlling the serial port and processing messages would be handled by a Python applicat... | Controlling serial port through a webapp(PHP, javascript) using MySQL and Python | 0.197375 | 0 | 0 | 743 |
6,791,799 | 2011-07-22T14:50:00.000 | 0 | 1 | 0 | 0 | javascript,php,python,mysql,serial-port | 10,899,487 | 2 | false | 1 | 0 | You might also want to check out pySerial (http://pyserial.sourceforge.net/). You might also want to think about you sampling rates, i.e. how much data are you going to be generating and at what frequency. in other words how much data are you planning to store. Will give you some idea of system sizing. | 2 | 1 | 0 | Wanted to get some feedback on this implementation.
I'm developing an application on the PC to send and receive data to the serial port.
Some of the data received by the application will be solicited, while other data unsolicited.
Controlling the serial port and processing messages would be handled by a Python applicat... | Controlling serial port through a webapp(PHP, javascript) using MySQL and Python | 0 | 0 | 0 | 743 |
6,791,916 | 2011-07-22T15:00:00.000 | 0 | 0 | 0 | 0 | python,stream | 17,312,308 | 2 | false | 0 | 0 | You can try using Scapy sniffing function sniff, append the captured packets to a list and do your extraction process. | 1 | 0 | 0 | i want to use python in combination with tcpdump to put the generated stream from tcpdump into a more readable way. There are some fields in the streams with interesting values.
I found some stuff here at stackoverflow regarding python and tcpdump but in my mind the best way is to put it in an array.
After this is done... | put stream from tcpdump into an array - which python version should i use? | 0 | 0 | 1 | 476 |
6,793,029 | 2011-07-22T16:24:00.000 | 2 | 0 | 0 | 0 | python,opengl,bioinformatics,vtk,protein-database | 6,793,800 | 3 | false | 0 | 0 | I think Pymol is not free anymore since it has to be purchased from Schrödinger.
Couple of free programs:
- JMol (bad!! don't use that except if you have no other choices)
- PyMol (if you are academic)
- Yasara
- Discovery studio (Accelrys)
- RasMol (No longer maintained)
- VMD (the best program for visualizing ... | 1 | 5 | 0 | I've been asked to work on Protein structure visualization, something like RasMol where a user will be opening a pdb file to get the protein structure.
How I can generate protein structure from the pdb file?
I would like to code in Python and to visualize the structure should I be using OpenGL or VTK? are there any oth... | Protein structure visualization | 0.132549 | 0 | 0 | 2,835 |
6,794,100 | 2011-07-22T17:56:00.000 | 0 | 1 | 0 | 0 | python,git,github,trac | 6,808,464 | 2 | false | 0 | 0 | We were trying to avoid opening a port on on our firewall, so we thought an email might be easier than using the post-receive url service hook. If we had a publicly hosted Trac instance, we would definitely go the rout of the post-receive url, but since we are hosted internally, this is not an option. | 1 | 1 | 0 | Any ideas on connecting GitHub with a locally hosted Trac 0.12 instance? We were thinking of using GitHub's email service hook to shoot off an email anytime GitHub is pushed to, which would fire off a script to have our local repo pull from GitHub, and also tell Trac to re-sync the repo. Any ideas to improve on what we... | Trying to connect Trac 0.12 (privately hosted) with GitHub | 0 | 0 | 0 | 161 |
6,794,454 | 2011-07-22T18:26:00.000 | 17 | 0 | 1 | 0 | python,json,pickle | 6,794,484 | 2 | true | 0 | 0 | json is more secure because it's fundamentally more limited. The only python types that a json document can encode are unicode, int, float, NoneType, bool, list and dict. these are marshaled/unmarshalled in a basically trivial fashion that isn't vulnerable to code injection attacks. | 1 | 12 | 0 | I recently came across the security problems of the Python pickle and cPickle modules.
Obviously, there are no real security measures implemented in pickle unless you overwrite
the find_class method as a basic modification to get a bit more security. But I often
heard that JSON is more secure.
Can anyone elaborate a bi... | JSON vs. Pickle security | 1.2 | 0 | 0 | 4,169 |
6,795,169 | 2011-07-22T19:37:00.000 | 0 | 0 | 0 | 0 | python,image,pygtk,glade | 7,046,931 | 1 | true | 0 | 1 | Glade does not allow for stretching images. This must be done in code, by scaling the pixbuf, creating a pixmap and mask from it, and then creating the image from the pixmap. | 1 | 1 | 0 | I'm using Python 2.7, PyGTK 2.24, and Glade 2.8.0. I'm trying to set an image to (stretch to) fill all of the given space, but I cannot find the properties to do that. Furthermore, I may need to shrink images to fit sometimes as well.
How do I do those two things in Glade? | Set Image to Fill PyGTK | 1.2 | 0 | 0 | 238 |
6,795,657 | 2011-07-22T20:20:00.000 | 0 | 0 | 1 | 0 | python,indexing,numpy,slice | 6,795,732 | 5 | false | 0 | 0 | I think you want to just do myslice = slice(1,2) to for example define a slice that will return the 2nd element (i.e. myarray[myslice] == myarray[1:2]) | 1 | 5 | 1 | In Numpy (and Python in general, I suppose), how does one store a slice-index, such as (...,0,:), in order to pass it around and apply it to various arrays? It would be nice to, say, be able to pass a slice-index to and from functions. | Numpy: arr[...,0,:] works. But how do I store the data contained in the slice command (..., 0, :)? | 0 | 0 | 0 | 389 |
6,795,719 | 2011-07-22T20:25:00.000 | 2 | 0 | 1 | 0 | python,forms,calendar,arcgis,arcpy | 7,691,860 | 1 | true | 0 | 0 | If you are running the script in an ArcGIS 10 toolbox, a calendar popup is not possible. Even worse, it does not look like the Date data type provides any validation from the toolbox. This means that you will need to either validate that an actual date has been entered in your code or you can modify the validation co... | 1 | 1 | 0 | I am a GIS Specialist using Python within ArcGIS10. I am creating a script and importing it into the the ArcGIS default graphical interface form. In the default forms, I can set certain parameters made of different data types. One of the parameters I would like to set is to have a field where the user opens a calendar ... | ArcGIS Python: Using Calendars in the Graphical Interface Forms | 1.2 | 0 | 0 | 428 |
6,798,305 | 2011-07-23T04:50:00.000 | 2 | 1 | 0 | 0 | python,perl,file-upload,node.js | 6,798,369 | 2 | true | 1 | 0 | If this isn't part of other program logic, a simple curl --upload-file <file> <url> would do the job. If not, like Dan Grossman commented, any language capable of opening a socket and write HTTP headers and body would work (all assuming your node.js server is speaking http). | 2 | 0 | 0 | I'm trying to figure out the best way to upload a file to a NodeJS(any server I guess, but just being specific) every 30 mins.
I was thinking about using perl or python to acheive this, or even NodeJS or a CGI script?
Would it be best to just create a multi-part form?
Trying to figure out the best practice.
Thanks. | Upload file to NodeJS server every 30 minutes | 1.2 | 0 | 0 | 598 |
6,798,305 | 2011-07-23T04:50:00.000 | 1 | 1 | 0 | 0 | python,perl,file-upload,node.js | 6,798,370 | 2 | false | 1 | 0 | I might recommend crontab for a job like this. It's a sort of job-scheduler for the operating system, and is designed for 'do this job every so often' tasks. | 2 | 0 | 0 | I'm trying to figure out the best way to upload a file to a NodeJS(any server I guess, but just being specific) every 30 mins.
I was thinking about using perl or python to acheive this, or even NodeJS or a CGI script?
Would it be best to just create a multi-part form?
Trying to figure out the best practice.
Thanks. | Upload file to NodeJS server every 30 minutes | 0.099668 | 0 | 0 | 598 |
6,800,534 | 2011-07-23T13:03:00.000 | 2 | 0 | 0 | 0 | python,numpy | 6,801,439 | 3 | false | 0 | 0 | Use A[n-offset]. this turns offset to offset+len(A) into 0 to len(A). | 2 | 1 | 1 | I need to create a numpy array of N elements, but I want to access the
array with an offset Noff, i.e. the first element should be at Noff and
not at 0. In C this is simple to do with some simple pointer arithmetic, i.e.
I malloc the array and then define a pointer and shift it appropriately.
Furthermore, I do not want... | numpy array access | 0.132549 | 0 | 0 | 2,276 |
6,800,534 | 2011-07-23T13:03:00.000 | 2 | 0 | 0 | 0 | python,numpy | 6,812,332 | 3 | false | 0 | 0 | I would be very cautious about over-riding the [] operator through the __getitem__() method. Although it will be fine with your own code, I can easily imagine that when the array gets passed to an arbitrary library function, you could get problems.
For example, if the function explicitly tried to get all values in the... | 2 | 1 | 1 | I need to create a numpy array of N elements, but I want to access the
array with an offset Noff, i.e. the first element should be at Noff and
not at 0. In C this is simple to do with some simple pointer arithmetic, i.e.
I malloc the array and then define a pointer and shift it appropriately.
Furthermore, I do not want... | numpy array access | 0.132549 | 0 | 0 | 2,276 |
6,800,641 | 2011-07-23T13:19:00.000 | 0 | 0 | 0 | 0 | javascript,python,progress | 6,800,883 | 1 | false | 1 | 0 | You can cut the python part in 2 functions and call first, then call 2nd when first is finished all with jQuery.ajax(...)
Or use HTML5 Web Sockets to discuss with server... | 1 | 1 | 0 | I have two functions that I need to run, both take quite some time to complete. The second is dependent on the first, so they need to be in order. The first MUST be done with an ajax call to Python from JavaScript (using jquery.ajax). The second is some parsing and HTML generation, so it can be done in either JavaSc... | Progress Update Between Python and jQuery.ajax Call | 0 | 0 | 0 | 554 |
6,802,119 | 2011-07-23T17:35:00.000 | 0 | 1 | 0 | 0 | python,pylint | 64,587,242 | 2 | false | 0 | 0 | Run pylint on dev branch, get x errors
Run pylint on master branch, get y errors
If y > x, which means you have new errors
You can do above things in CI process, before code is merged to master | 2 | 8 | 0 | Does anybody know how to distinguish new errors (those that were found during latest Pylint execution) and old errors (those that were alredy found during previous executions) in the Pylint report?
I'm using Pylint in one of my projects, and the project is pretty big. Pylint reports pretty many errors (even though I di... | Pylint - distinguish new errors from old ones | 0 | 0 | 0 | 925 |
6,802,119 | 2011-07-23T17:35:00.000 | 4 | 1 | 0 | 0 | python,pylint | 6,805,524 | 2 | true | 0 | 0 | Two basic approaches. Fix errors as they appear so that there will be no old ones. Or, if you have no intention of fixing certain types of lint errors, tell lint to stop reporting them.
If you have a lot of files it would be a good idea to get a lint report for each file separately, commit the lint reports to revision ... | 2 | 8 | 0 | Does anybody know how to distinguish new errors (those that were found during latest Pylint execution) and old errors (those that were alredy found during previous executions) in the Pylint report?
I'm using Pylint in one of my projects, and the project is pretty big. Pylint reports pretty many errors (even though I di... | Pylint - distinguish new errors from old ones | 1.2 | 0 | 0 | 925 |
6,802,638 | 2011-07-23T19:06:00.000 | 0 | 1 | 0 | 0 | python,email,queue,scheduling | 6,806,145 | 3 | false | 0 | 0 | In my app, I insert emails in DB table, and I have python script running under cron that checks this table and sends email updating record as sent. | 2 | 0 | 0 | I have a Pyramid web application that needs to send emails such as confirmation emails after registration, newsletters and so forth. I know how to send emails using smtplib in python and I decided on an smtp service (I think sendgrid will do the trick).
The real problem is the scheduling and delay sending of the emails... | Best way to do email scheduling on a python web application? | 0 | 0 | 0 | 493 |
6,802,638 | 2011-07-23T19:06:00.000 | 0 | 1 | 0 | 0 | python,email,queue,scheduling | 6,802,910 | 3 | false | 0 | 0 | The existing solution to which you refer is to run your own SMTP server on the machine, bound only to localhost to prevent any other machines from connecting to it. Since you're the only one using it, submitting a message to it should be close to instantaneous, and the server will handle queuing, retries, etc. If you a... | 2 | 0 | 0 | I have a Pyramid web application that needs to send emails such as confirmation emails after registration, newsletters and so forth. I know how to send emails using smtplib in python and I decided on an smtp service (I think sendgrid will do the trick).
The real problem is the scheduling and delay sending of the emails... | Best way to do email scheduling on a python web application? | 0 | 0 | 0 | 493 |
6,803,126 | 2011-07-23T20:31:00.000 | 3 | 1 | 1 | 0 | python,time,module,loading | 6,803,141 | 2 | false | 0 | 0 | When you import a module test.py, Python must read the source and convert it into the bytecode Python can execute. This takes time, but Python will store this in test.pyc. This Bytecode is the result of breaking your code down into simpler terms able to run directly on the CPython Virtual Machine.
If you load test.pyc,... | 1 | 3 | 0 | I am quoting a part of Python documentation:
"A program doesn’t run any faster when it is read from a .pyc or .pyo file than when it is read from a .py file; the only thing that’s faster about .pyc or .pyo files is the speed with which they are loaded."
I don't understand what does it mean when it says it doesn't affec... | Difference between loading time and running time in python? | 0.291313 | 0 | 0 | 365 |
6,803,597 | 2011-07-23T22:04:00.000 | 0 | 0 | 1 | 0 | python,class,types,wrapper | 6,803,712 | 6 | false | 0 | 0 | It sounds like you want to test the type of the object your DocumentWrapper wraps, not the type of the DocumentWrapper itself. If that's right, then the interface to DocumentWrapper needs to expose that type. You might add a method to your DocumentWrapper class that returns the type of the wrapped object, for instance.... | 1 | 24 | 0 | I recently developed a class named DocumentWrapper around some ORM document object in Python to transparently add some features to it without changing its interface in any way.
I just have one issue with this. Let's say I have some User object wrapped in it. Calling isinstance(some_var, User) will return False because ... | How to fake type with Python | 0 | 0 | 0 | 12,428 |
6,804,243 | 2011-07-24T00:40:00.000 | 2 | 0 | 1 | 0 | python | 6,804,252 | 1 | true | 1 | 0 | You mean when executing those statements on the command line? The difference is "python scriptname.py" explicitly invokes the program named "python" in your path (in Linux, typing "which python" will tell you where the program lives), wheras "scriptname.py" is just executing that file, feeding it to the shell for inte... | 1 | 1 | 0 | what's the difference between "python scriptname.py" and just "scriptname.py"?
I meet the problem when using commands in Django, and this really confuse me | what's the difference between "python scriptname.py" and just "scriptname.py" | 1.2 | 0 | 0 | 243 |
6,805,180 | 2011-07-24T05:53:00.000 | 0 | 0 | 0 | 0 | python,selenium,selenium-rc,locate,user-extensions.js | 6,819,144 | 1 | false | 0 | 0 | The problem is most likely that your custom locator function (LocateElementByMyprefix()) is not being registered. Selenium RC does user-extension.js setup just a little differently from Selenium IDE, and the timing can get in the way. Try calling selenium.browserbot._registerAllLocatorFunctions() after your function ... | 1 | 0 | 0 | I have written a custom assert function in user-extensions.js that uses a custom locator function - also implemented in user-extensions.js - to locate a particular element on a page.
Without getting into details; I need the custom locator function because I'm trying to locate an element in a different namespace on the... | Calling custom assert function from Selenium RC (Python) with a custom locator function in user-extensions.js | 0 | 0 | 1 | 592 |
6,805,977 | 2011-07-24T09:16:00.000 | 3 | 0 | 1 | 0 | python,constants,projects | 6,805,980 | 4 | true | 0 | 0 | Create a Python package and import it in the various projects... | 3 | 1 | 0 | What would be a neat way to share configuration parameters\settings\constants between various projects in Python?
Using a DB seems like an overkill. Using a file raises the question of which project should host the file in its source control...
I'm open for suggestions :)
UPDATE:
For clarification - assume the various ... | Sharing settings\constants between Python projects | 1.2 | 0 | 0 | 1,865 |
6,805,977 | 2011-07-24T09:16:00.000 | 3 | 0 | 1 | 0 | python,constants,projects | 6,806,127 | 4 | false | 0 | 0 | Why don't you just have a file named constants.py and just have CONSTANT = value | 3 | 1 | 0 | What would be a neat way to share configuration parameters\settings\constants between various projects in Python?
Using a DB seems like an overkill. Using a file raises the question of which project should host the file in its source control...
I'm open for suggestions :)
UPDATE:
For clarification - assume the various ... | Sharing settings\constants between Python projects | 0.148885 | 0 | 0 | 1,865 |
6,805,977 | 2011-07-24T09:16:00.000 | 2 | 0 | 1 | 0 | python,constants,projects | 6,806,498 | 4 | false | 0 | 0 | Why is a database overkill? You're describing sharing data across different projects located on different physical systems with different paths to each project's directory. Oh, and sometimes the projects just aren't there. I can't imagine a better means of communicating the data. It only has to be a single table, that'... | 3 | 1 | 0 | What would be a neat way to share configuration parameters\settings\constants between various projects in Python?
Using a DB seems like an overkill. Using a file raises the question of which project should host the file in its source control...
I'm open for suggestions :)
UPDATE:
For clarification - assume the various ... | Sharing settings\constants between Python projects | 0.099668 | 0 | 0 | 1,865 |
6,806,266 | 2011-07-24T10:30:00.000 | 1 | 1 | 1 | 0 | python,git | 6,806,465 | 4 | false | 0 | 0 | I really advise using only the command line git, git-python its used for macros or complicated things, not just for pulling, pushing or cloning :) | 1 | 2 | 0 | am working on a code which I would like to retrieve the commits from a repository on github. Am not entirely sure how to do such a thing, I got git-python but most the api's are for opening a local git repository on the same file system.
Can someone advice?
regards, | git-python get commit feed from a repository | 0.049958 | 0 | 0 | 10,402 |
6,806,467 | 2011-07-24T11:21:00.000 | 2 | 0 | 1 | 0 | python,datetime,time,modulo,rounding | 6,806,625 | 7 | false | 0 | 0 | I think I'd convert the time in seconds, and use standard modulo operation from that point.
20:11:13 = 20*3600 + 11*60 + 13 = 72673 seconds
72673 % 10 = 3
72673 % (10*60) = 73
This is the easiest solution I can think about. | 1 | 32 | 0 | What would be an elegant, efficient and Pythonic way to perform a h/m/s rounding operation on time related types in Python with control over the rounding resolution?
My guess is that it would require a time modulo operation. Illustrative examples:
20:11:13 % (10 seconds) => (3 seconds)
20:11:13 % (10 minutes) => (1 mi... | Rounding time in Python | 0.057081 | 0 | 0 | 91,786 |
6,807,808 | 2011-07-24T15:44:00.000 | 0 | 0 | 1 | 0 | python,ncurses,tui | 6,808,886 | 2 | false | 0 | 1 | I don't know anything about ncurses, but using Tkinter or one of the other GUI toolkits, it could be done with a canvas. You would first set the scroll region, then
bind the "h" key so it sets a highlight variable to True,
bind a mouse click to a function that retrieves the location to start,
bind the left and right... | 1 | 8 | 0 | This is my first post to stack overflow. I've been lurking this site for information for years, and it's always helpful, so I thought that I would post my first question.
I've been searching for some similar examples, but can't seem to find anything.
Ultimately, I'm trying to write a simple text ui for finding false ... | Highlighting and Selecting text with Python curses | 0 | 0 | 0 | 9,844 |
6,807,876 | 2011-07-24T15:56:00.000 | 2 | 0 | 1 | 0 | python | 6,808,170 | 4 | true | 0 | 0 | @ezod, there is no direct way to do what you're asking for, even with the descriptors protocol.
That kind behaviour of value property totally breaks the semantics of += operator. | 3 | 5 | 0 | Consider the following simple example class, which has a property that exposes a modified version of some internal data when called:
class Foo(object):
def __init__(self, value, offset=0):
self._value = value
self.offset = offset
@property
def value(self):
return self._value + self.... | Property setters for compound assignment? | 1.2 | 0 | 0 | 544 |
6,807,876 | 2011-07-24T15:56:00.000 | 0 | 0 | 1 | 0 | python | 6,808,440 | 4 | false | 0 | 0 | The desired behavior is that x.value += 5 should be equivalent to
x.value = x._value + 5
Why should Python know how you property is implemented (i.e. that setter assigns its value exactly to _x)?
Protocol of property gives you a possibility assign different actions (get, set, delete) to one name. And this protocol ... | 3 | 5 | 0 | Consider the following simple example class, which has a property that exposes a modified version of some internal data when called:
class Foo(object):
def __init__(self, value, offset=0):
self._value = value
self.offset = offset
@property
def value(self):
return self._value + self.... | Property setters for compound assignment? | 0 | 0 | 0 | 544 |
6,807,876 | 2011-07-24T15:56:00.000 | 1 | 0 | 1 | 0 | python | 6,807,922 | 4 | false | 0 | 0 | Override the __iadd__ magic method.
You need to do that because += means "take the value and add five, then set that as the result". If you want it to know that the value isn't really the value, you need to change the semantics of the += operator. | 3 | 5 | 0 | Consider the following simple example class, which has a property that exposes a modified version of some internal data when called:
class Foo(object):
def __init__(self, value, offset=0):
self._value = value
self.offset = offset
@property
def value(self):
return self._value + self.... | Property setters for compound assignment? | 0.049958 | 0 | 0 | 544 |
6,808,064 | 2011-07-24T16:26:00.000 | 0 | 0 | 1 | 0 | python,parsing,calendar | 6,808,089 | 6 | false | 0 | 0 | I'm sure you can represent the given time as a TimeDelta object. From there I am sure there is an easy way to represent the TimeDelta in minutes. | 1 | 7 | 0 | Sometimes I get a string like "02:40" indicating 2 hours and 40 minutes. I'd like to parse that string into the number of minutes (160 in this case) using Python.
Sure, I can parse the string and multiply the hours by 60, but is there something in the standard lib that does this? | Parsing hh:mm in Python | 0 | 0 | 0 | 10,498 |
6,809,099 | 2011-07-24T19:25:00.000 | 0 | 0 | 0 | 1 | python,windows,ntfs | 6,812,994 | 3 | false | 0 | 0 | depending on your needs, you can use GetFileAttributes and check ntfs File Attribute Constants. | 1 | 0 | 0 | Is there a Windows API for determining if a certain file (path) is on an NTFS filesystem?
If this can be somehow inferred from an existing Python API, all the better. | Determine if a file is on an NTFS filesystem | 0 | 0 | 0 | 1,048 |
6,809,998 | 2011-07-24T21:53:00.000 | 4 | 0 | 1 | 0 | c++,python,ruby,overloading,overriding | 6,810,023 | 3 | true | 0 | 0 | Function overloading is (at least in C++) handled internally inside the compiler. The idea is that the code that the compiler ultimately generates will be hardcoded to call the appropriate function, as if the functions all had different names and you called the function uniquely suited to the arguments. More generall... | 2 | 5 | 0 | Where in the process of creating the program, compiler, linker etc., is the overriding of functions and operator overloading done?
I'm particularly interested where it is done in C++, Ruby and Python. | Where is function overriding done? | 1.2 | 0 | 0 | 850 |
6,809,998 | 2011-07-24T21:53:00.000 | 0 | 0 | 1 | 0 | c++,python,ruby,overloading,overriding | 6,810,458 | 3 | false | 0 | 0 | Python is not linked/compiled, it is interpreted.
So, the normal overriding is done when class sources are parsed. Of course, due to dynamic nature you can always override during the runtime as well.
I suppose that alternate implementations using the byto-code compilation do it on the compile-time.
I also think the abo... | 2 | 5 | 0 | Where in the process of creating the program, compiler, linker etc., is the overriding of functions and operator overloading done?
I'm particularly interested where it is done in C++, Ruby and Python. | Where is function overriding done? | 0 | 0 | 0 | 850 |
6,810,977 | 2011-07-25T01:24:00.000 | 74 | 1 | 0 | 0 | php,python,ruby,perl,node.js | 6,811,003 | 4 | true | 1 | 0 | You're not going to have any improvement as the whitespaces and all formatting are lost when your server side code is translated to machine code (or interpreted). It's also not sent over the wire, it's read from the local filesystem, so while having less characters would lead to a faster startup, it would not make any ... | 3 | 36 | 0 | When it comes to the frontend code you always minify it (remove white spaces, comments etc) in production.
Should one do the same with server code? I usually have a lot of comments in my server files. But I have never heard about people doing so.
Wouldn't the server run faster if the code was optimized in the same way? | Should one minify server code when it's in production? | 1.2 | 0 | 0 | 3,747 |
6,810,977 | 2011-07-25T01:24:00.000 | 18 | 1 | 0 | 0 | php,python,ruby,perl,node.js | 6,811,008 | 4 | false | 1 | 0 | I think that minification has more to do with reducing bytes on the wire than it does runtime efficiency. | 3 | 36 | 0 | When it comes to the frontend code you always minify it (remove white spaces, comments etc) in production.
Should one do the same with server code? I usually have a lot of comments in my server files. But I have never heard about people doing so.
Wouldn't the server run faster if the code was optimized in the same way? | Should one minify server code when it's in production? | 1 | 0 | 0 | 3,747 |
6,810,977 | 2011-07-25T01:24:00.000 | 6 | 1 | 0 | 0 | php,python,ruby,perl,node.js | 6,811,024 | 4 | false | 1 | 0 | i do not believe this offers any benefit to server side code since the server evaluates the code and doesn't actually send it down. If you are looking to optimize production code you can look into setting up a compiler cache such as APC for PHP | 3 | 36 | 0 | When it comes to the frontend code you always minify it (remove white spaces, comments etc) in production.
Should one do the same with server code? I usually have a lot of comments in my server files. But I have never heard about people doing so.
Wouldn't the server run faster if the code was optimized in the same way? | Should one minify server code when it's in production? | 1 | 0 | 0 | 3,747 |
6,812,571 | 2011-07-25T06:45:00.000 | 8 | 0 | 1 | 0 | python,memory-efficient | 6,812,809 | 1 | true | 0 | 0 | It sounds like you aren't worried about time cost (good; that would be silly, since modules are only imported once) but memory cost. I put it to you: if you need all the functionality in these modules, then how exactly do you plan to avoid having them all in memory? Might as well just import things in the most logical ... | 1 | 5 | 0 | The memory cost obviously depends on exactly how large a module is, but I'm only looking for a general answer: Is it generally expensive or cheap to import a module in Python? If I have a few tens of small scripts that potentially stay in memory for the whole duration of the application, how much will that hog the memo... | Python: Memory cost of importing a module | 1.2 | 0 | 0 | 1,466 |
6,813,837 | 2011-07-25T09:07:00.000 | -3 | 0 | 1 | 0 | python,unit-testing,testcase,test-suite | 6,813,892 | 6 | false | 0 | 0 | You can use sys.exit() to close the python interpreter at any point within your testcase. | 1 | 11 | 0 | I have a testSuite in Python with several testCases.
If a testCase fails, testSuite continues with the next testCase. I would like to be able to stop testSuite when a testCase fails or be able to decide if the testSuite should continue or stop. | Stop testsuite if a testcase find an error | -0.099668 | 0 | 0 | 7,726 |
6,817,600 | 2011-07-25T14:23:00.000 | 0 | 0 | 0 | 0 | python,tkinter | 6,818,171 | 2 | false | 0 | 1 | Well tkinter uses the PIL for most of its advanced image stuff, in which case this problem is quite simple: Just use Image.frombuffer(mode, size, data) with the bytebuffer representing the image and then save it ala im.save(filename)- if you want a special format you can also specify it.
If you want to do it without th... | 1 | 0 | 0 | the subject says it all: is it possible to take an image present in the clipboard and save it to file under Tkinter? | save the image in the clipboatd - in Python/Tkinter | 0 | 0 | 0 | 951 |
6,818,610 | 2011-07-25T15:38:00.000 | 2 | 0 | 0 | 0 | python,math,rounding | 6,818,940 | 4 | false | 1 | 0 | You are experiencing Python 2's integer division. When you divide two integers, Python (and many other languages) throw away the remainder. You'll want to divide by a float instead of an integer, as Dogbert indicated. | 2 | 1 | 0 | In order to sync my iPod and my local music repository, I created a unique key for each track using its metadata. The unique track consists of the track's following metadata fields:
artist, album, track number, duration. The iPod saves the track's duration in milliseconds, but my local repository saves it in seconds. F... | Compare "similar" numbers in Python | 0.099668 | 0 | 0 | 1,316 |
6,818,610 | 2011-07-25T15:38:00.000 | -2 | 0 | 0 | 0 | python,math,rounding | 6,818,771 | 4 | false | 1 | 0 | Honestly, I think you nailed it already with the floor and ceil calls, but for somplicity you might want to do floor((ipodtime/1000)+1) == localrepostime to check equality since the ipod time seems to round down no matter what. | 2 | 1 | 0 | In order to sync my iPod and my local music repository, I created a unique key for each track using its metadata. The unique track consists of the track's following metadata fields:
artist, album, track number, duration. The iPod saves the track's duration in milliseconds, but my local repository saves it in seconds. F... | Compare "similar" numbers in Python | -0.099668 | 0 | 0 | 1,316 |
6,819,610 | 2011-07-25T16:50:00.000 | 4 | 0 | 1 | 0 | python,deep-copy,copy-on-write | 6,819,636 | 3 | false | 0 | 0 | No, it doesn't it, just copies the objects. And it also must copy immutable objects if they reference mutables. | 1 | 5 | 0 | I wonder if the python interpreter applies copy on write strategy when doing a deepcopy on mutable objects.
Also, I'd like to know if the deepcopy is performed also on nonmutable object (that would seem strange to me however) | Does deepcopy use copy-on-write? | 0.26052 | 0 | 0 | 860 |
6,819,653 | 2011-07-25T16:55:00.000 | 1 | 0 | 0 | 0 | python,plot | 6,819,725 | 8 | false | 0 | 0 | You could always write a plotting function that uses the turtle module from the standard library. | 1 | 10 | 1 | I want to plot some (x,y) points on the same graph and I don't need any special features at all short of support for polar coordinates which would be nice but not necessary. It's mostly for visualizing my data. Is there a simple way to do this? Matplotlib seems like way more than I need right now. Are there any more ba... | Plotting points in python | 0.024995 | 0 | 0 | 69,333 |
6,820,856 | 2011-07-25T18:49:00.000 | 1 | 0 | 1 | 1 | python,winapi,subprocess | 6,820,974 | 1 | true | 0 | 0 | If you want to wait for a spawned process, then use subprocess.Popen and then either wait or communicate. start is AFAIR a shell construct, not a real exec (so you'd have to use shell = True — but that still wouldn't do what you want). | 1 | 0 | 0 | I've used Python's subprocess.call() before, but how do you get it to act like the Windows START /WAIT myprogram?
I've tried subprocess.call(['start', '/wait', 'myprogram.exe']) but it can't find start and neither can I. | python: executing "start /wait someprocess" | 1.2 | 0 | 0 | 127 |
6,822,884 | 2011-07-25T22:00:00.000 | 2 | 1 | 0 | 0 | python,pdf,indexing,solr | 6,827,387 | 3 | false | 0 | 0 | I once solved this by converting the PDF files to text with utilities as pdftotext (pdftohtml would also work I guess), generating a 'cache' of some sorts. Then using some grep I searched the text file cache for keywords.
This is slightly different from your proposed solution, but I can imagine you can call this from P... | 1 | 8 | 0 | What I have is a bunch of PDFs (few 100s). They don't have a proper structure nor do they have particular fields. All they have is lot of text.
What I am trying to do :
Index the PDFs and search for some keywords against the index.
I am interested in finding if that particular keyword is in the PDF doc and if it is,... | How do I Index PDF files and search for keywords? | 0.132549 | 0 | 0 | 13,288 |
6,823,316 | 2011-07-25T22:47:00.000 | 3 | 1 | 1 | 0 | python,iis | 25,462,179 | 4 | false | 1 | 0 | just make sure the path to the directory holding the cgi scripts doesn't have spaces or &.
i tried lots of things for many days and nothing worked then i changed the path and it worked
UPDATE:
If it has spaces, put quotes around the path, but not the %s %s
like this:
"C:\Program Files\Python36\python.exe" %s %s | 1 | 66 | 0 | I've got a background in PHP, dotNet and am charmed by Python. I want to transpose functionality from PHP to Python step by step, running bits and pieces side-by-side. During this transition, which could take 2 years since the app is enormous, I am bound to IIS. I've got 15 years background of web-programming, includin... | Python on IIS: how? | 0.148885 | 0 | 0 | 85,151 |
6,823,783 | 2011-07-25T23:45:00.000 | 0 | 0 | 1 | 1 | python | 6,824,421 | 1 | false | 0 | 0 | The PYTHONPATH environment variable is essentially the same thing. Set it to a directory containing Python modules or packages and it will be added to sys.path at initialization. | 1 | 0 | 0 | Is it possible to specify site directories through python command line or environment?
Right now I'm using site.addsitedir, but I would like to make the script agnostic of the site-setting logic | Specifying site directory outside of the script | 0 | 0 | 0 | 50 |
6,824,062 | 2011-07-26T00:39:00.000 | 0 | 0 | 0 | 0 | javascript,jquery,python,ajax | 6,824,093 | 2 | false | 1 | 0 | Try to implement a loader with a freezing background. | 2 | 0 | 0 | I'm using jQuery's $.ajax() to send Ajax request to server and bring back a large chunk of HTML content to replace the content of a div. Everything works fine except for the problem that while the div is being updated, the page is kind of frozen (even the vertical scroll bar is not draggable). It comes back to normal a... | Page scroll bar freezes while div is updated by Ajax responseText | 0 | 0 | 1 | 510 |
6,824,062 | 2011-07-26T00:39:00.000 | 0 | 0 | 0 | 0 | javascript,jquery,python,ajax | 6,825,203 | 2 | false | 1 | 0 | Can you link your ajax code? I think you are doing a sync call, try setting async: true.
Still without the code thats all I can think about. | 2 | 0 | 0 | I'm using jQuery's $.ajax() to send Ajax request to server and bring back a large chunk of HTML content to replace the content of a div. Everything works fine except for the problem that while the div is being updated, the page is kind of frozen (even the vertical scroll bar is not draggable). It comes back to normal a... | Page scroll bar freezes while div is updated by Ajax responseText | 0 | 0 | 1 | 510 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.