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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4,898,066 | 2011-02-04T12:39:00.000 | 0 | 0 | 0 | 0 | python,http,xmlhttprequest | 4,898,364 | 3 | false | 1 | 0 | There's absolutely no need to write your own web server. Plenty of options exist, including lightweight ones like nginx.
You should use one of those, and either your own custom WSGI code to receive the request, or (better) one of the microframeworks like Flask or Bottle. | 1 | 1 | 0 | I am currently working on a project to create simple file uploader site that will update the user of the progress of an upload.
I've been attempting this in pure python (with CGI) on the server side but to get the progress of the file I obviously need send requests to the server continually. I was looking to use AJAX ... | Creating a python web server to recieve XML HTTP Requests | 0 | 0 | 1 | 1,735 |
4,898,747 | 2011-02-04T13:57:00.000 | 2 | 0 | 0 | 0 | python,project,pygtk | 4,898,798 | 6 | false | 0 | 1 | Writing a program will help you learn the language, but IMHO joining the development team of an open-source python project would help you learn even more, as reading high-quality code written by other developers will disclose to you features of the language that you would never discover alone.
So, my suggestion is to h... | 2 | 2 | 0 | I'm a 2nd year university student, and I thought it would be a good idea to expand my abilities. I will be using python later this year to complete a gui for a C program (using Tkinter), but I want to make a side project as well, and python seems like a great language to do it with.
I want a project which has multipl... | A good side-project for learning python? | 0.066568 | 0 | 0 | 9,115 |
4,898,747 | 2011-02-04T13:57:00.000 | 10 | 0 | 0 | 0 | python,project,pygtk | 4,898,770 | 6 | true | 0 | 1 | Considering I have no python experience, but I do have a strong background in C and Java, are there going to be any difficulties which will unexpectedly stop me?
Yes.
I have never made a music application before, and I am not sure whats involved in keeping a music library, for example.
That will stop you.
Want adv... | 2 | 2 | 0 | I'm a 2nd year university student, and I thought it would be a good idea to expand my abilities. I will be using python later this year to complete a gui for a C program (using Tkinter), but I want to make a side project as well, and python seems like a great language to do it with.
I want a project which has multipl... | A good side-project for learning python? | 1.2 | 0 | 0 | 9,115 |
4,899,158 | 2011-02-04T14:33:00.000 | 1 | 1 | 0 | 0 | python,com | 4,899,486 | 1 | false | 0 | 1 | Most likely, regsvr32.exe which registers you COM component couldn't find a DLL that your COM component needs.
I'm not familiar with Python COM components but is there some way you can run depends.exe on it? This is the usual way to track down binary dependency problems. | 1 | 0 | 0 | i've built a com component which utilizes libxml2 python bindings , the build is successfull but when i try to register the component i get "specified module could not be found , unable to load python dll" this is the error i get when the component is built using the bundle files option set as 1
if i build the componen... | python com component does not register when using libxml2 on win7 | 0.197375 | 0 | 0 | 240 |
4,901,039 | 2011-02-04T17:30:00.000 | 1 | 1 | 0 | 0 | php,python,dynamic,static,archive | 4,901,187 | 3 | false | 1 | 0 | Using PHP you could write a simple script that would do this:
Save current page.
Follow links from that page and saving those pages (and for each page repeat from 1).
Replace URLs on current page with those leading to saved pages. | 1 | 1 | 0 | I have a PHP/mySQL site that is no longer going to get any new content added. But I'd like to keep what I do have as an archive and keep it online. Ideally I'd like to convert it to a static site so that it no longer requires a database.
If anyone else has gone through this process, are there any tools, scripts, or met... | Converting a dynamic PHP/mySQL website to an archived HTML version? | 0.066568 | 0 | 0 | 1,156 |
4,902,366 | 2011-02-04T20:00:00.000 | 0 | 0 | 1 | 0 | python,networking | 4,902,384 | 1 | true | 0 | 0 | That's not an error, it's a warning. You're using code written for python 2.5 or earlier, before there was a hashlib module. | 1 | 0 | 0 | am using Python brisa Framework to implement UpnP protocols. I was trying to make a device but while executing it in ubuntu linux env, it throws me an error.What does thsi eror mean? DO i need to change the framework files??
/usr/local/lib/python2.6/dist-packages/cherrypy/lib/cptools.py:4: DeprecationWarning: the md5 m... | python compilation error | 1.2 | 0 | 0 | 178 |
4,902,933 | 2011-02-04T21:05:00.000 | 2 | 0 | 0 | 0 | c#,web-services,ironpython,openrasta | 4,903,621 | 2 | false | 1 | 0 | Per request is the way to go unless all of your code is thread safe. You may get better performance using per application (per session implies you have th notion of "sesions" between you client and server), however the implication there is that all of your code in the "application" is thread safe.
So per-request is wha... | 2 | 1 | 0 | I have a RESTful C# web service (using Open Rasta) that I want to run IronPython scripts that talk to a CouchDB.
One thing I could use some clarification on is: How often do I need a new instance of the python engine and the scope? one each per application? per session? per request?
I currently have a static engine at ... | RESTful Webservice with embedded IronPython: engine & scope questions | 0.197375 | 0 | 0 | 627 |
4,902,933 | 2011-02-04T21:05:00.000 | 3 | 0 | 0 | 0 | c#,web-services,ironpython,openrasta | 4,903,789 | 2 | true | 1 | 0 | A ScriptRuntime/ScriptEngine per application and a Scope per request is exactly how it should be done. Runtimes/Engine are thread-safe and Scopes are not. | 2 | 1 | 0 | I have a RESTful C# web service (using Open Rasta) that I want to run IronPython scripts that talk to a CouchDB.
One thing I could use some clarification on is: How often do I need a new instance of the python engine and the scope? one each per application? per session? per request?
I currently have a static engine at ... | RESTful Webservice with embedded IronPython: engine & scope questions | 1.2 | 0 | 0 | 627 |
4,905,368 | 2011-02-05T05:50:00.000 | 8 | 0 | 0 | 0 | python,nltk | 4,908,925 | 3 | false | 0 | 0 | There's 2 options that I know of:
1) Periodically retrain the classifier on the new data. You'd accumulate new training data in a corpus (that already contains the original training data), then every few hours, retrain & reload the classifier. This is probably the simplest solution.
2) Externalize the internal model, t... | 1 | 17 | 1 | I am working on a project to classify snippets of text using the python nltk module and the naivebayes classifier. I am able to train on corpus data and classify another set of data but would like to feed additional training information into the classifier after initial training.
If I'm not mistaken, there doesn't app... | How to incrementally train an nltk classifier | 1 | 0 | 0 | 3,608 |
4,906,246 | 2011-02-05T10:07:00.000 | 2 | 0 | 1 | 0 | python,django,init,pycharm | 40,809,492 | 7 | false | 1 | 0 | I worked out this fix:
Go to Preferences > Project:{YourProject} > Python interpreter.
I saw that the field for "Project interpreter" said "2.7...", but I was coding with python 3.4 and my project was created with python 3.4. Replace the version of python in the "Project interpreter" field with the Python version by m... | 4 | 18 | 0 | My Python IDE (pycharm) has stopped auto completing my modules (suggestions). I get unresolved references after every django module I try to import so:
from django - works, however soon as I add a 'dot' it fails so from django.db import models gives me unresolved errors...
The ackward thing is after compiling reference... | Pycharm (Python IDE) doesn't auto complete Django modules | 0.057081 | 0 | 0 | 14,576 |
4,906,246 | 2011-02-05T10:07:00.000 | 0 | 0 | 1 | 0 | python,django,init,pycharm | 56,934,298 | 7 | false | 1 | 0 | you should just change your project interpreter if it is using anaconda or etc to standard python interpreter which may be located in this path (C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\python.exe) | 4 | 18 | 0 | My Python IDE (pycharm) has stopped auto completing my modules (suggestions). I get unresolved references after every django module I try to import so:
from django - works, however soon as I add a 'dot' it fails so from django.db import models gives me unresolved errors...
The ackward thing is after compiling reference... | Pycharm (Python IDE) doesn't auto complete Django modules | 0 | 0 | 0 | 14,576 |
4,906,246 | 2011-02-05T10:07:00.000 | 2 | 0 | 1 | 0 | python,django,init,pycharm | 24,810,990 | 7 | false | 1 | 0 | Trivial solution that worked for me: start a new django project using pycharm project options. Try auto-completing using a django import module. If it works, switch back to your original project and auto-complete should be working fine.
I still don't understand why this works. | 4 | 18 | 0 | My Python IDE (pycharm) has stopped auto completing my modules (suggestions). I get unresolved references after every django module I try to import so:
from django - works, however soon as I add a 'dot' it fails so from django.db import models gives me unresolved errors...
The ackward thing is after compiling reference... | Pycharm (Python IDE) doesn't auto complete Django modules | 0.057081 | 0 | 0 | 14,576 |
4,906,246 | 2011-02-05T10:07:00.000 | 21 | 0 | 1 | 0 | python,django,init,pycharm | 7,276,265 | 7 | false | 1 | 0 | I had exactly the same issue and couldn't find a definitive answer. Just invalidating caches didn't work for me. The problem lies in the fact that, at some point, __init__.py files got registered as text files and messed up the indexing. I worked out this fix:
Preferences > File Types > Text Files.
Remove __init__.py ... | 4 | 18 | 0 | My Python IDE (pycharm) has stopped auto completing my modules (suggestions). I get unresolved references after every django module I try to import so:
from django - works, however soon as I add a 'dot' it fails so from django.db import models gives me unresolved errors...
The ackward thing is after compiling reference... | Pycharm (Python IDE) doesn't auto complete Django modules | 1 | 0 | 0 | 14,576 |
4,906,424 | 2011-02-05T10:51:00.000 | 1 | 0 | 0 | 1 | python,perl,gtk | 4,906,739 | 2 | false | 0 | 1 | I'm not really into GTK programming, but as far as i know you want to set an "URGENT"-Flag for the Window which should be highlighted. Maybe this will get you any further. :) | 1 | 1 | 0 | In order to indicate activity, some applications (e.g. Pidgin) highlight their entry in GNOME's Window List panel widget (e.g. via bold font or flashing color). This indication is reset automatically when the window is activated.
I have a terminal application for which I would like to achieve the same thing (preferably... | highlighting a window in GNOME's window list | 0.099668 | 0 | 0 | 495 |
4,907,828 | 2011-02-05T15:49:00.000 | 0 | 0 | 0 | 1 | python,windows,gstreamer,alsa | 4,925,220 | 4 | false | 0 | 0 | 9000's answer, sdl, and autoaudiosrc/sink are the answer :) | 3 | 2 | 0 | Does anyone know an alternative to ALSA that can be used on windows, with gstreamer, and how to install it, and where to find python bindings for it if it needs it?
thanks xxx | Windows Gstreamer ALSA Alternative? | 0 | 0 | 0 | 2,273 |
4,907,828 | 2011-02-05T15:49:00.000 | 0 | 0 | 0 | 1 | python,windows,gstreamer,alsa | 4,907,925 | 4 | false | 0 | 0 | It seems that on Windows the SDK installer doesn't actually install the bindings to any location visible to the Python interpreter. You can find the files at sdk\bindings\python\v2.6\lib\site-packages. Copy the contents of the directory to your Python installation's site-packages, and you should be able to import the l... | 3 | 2 | 0 | Does anyone know an alternative to ALSA that can be used on windows, with gstreamer, and how to install it, and where to find python bindings for it if it needs it?
thanks xxx | Windows Gstreamer ALSA Alternative? | 0 | 0 | 0 | 2,273 |
4,907,828 | 2011-02-05T15:49:00.000 | 3 | 0 | 0 | 1 | python,windows,gstreamer,alsa | 5,058,755 | 4 | true | 0 | 0 | SDL does a decent job of abstracting sound interfaces in a platform-independent way. PyGame contains an interface to SDL and works on many platforms. Such abstraction, of course, sets many limitations, but maybe it will still do for you.
Converted from a comment. | 3 | 2 | 0 | Does anyone know an alternative to ALSA that can be used on windows, with gstreamer, and how to install it, and where to find python bindings for it if it needs it?
thanks xxx | Windows Gstreamer ALSA Alternative? | 1.2 | 0 | 0 | 2,273 |
4,908,683 | 2011-02-05T18:19:00.000 | 9 | 0 | 1 | 0 | python,vm-implementation | 4,908,699 | 1 | true | 0 | 0 | In CPython (the standard Python implementation) the first time a Python module is imported, it's compiled to bytecode and stored in a .pyc file. From then on, the .pyc file is read and interpreted by the VM when needed. Once the .pyc is read into memory, the bytecode is in memory, and interpreted by the VM when the f... | 1 | 1 | 0 | If I have a function that is called in few places in my module, does the virtual machine compiles it to native code only the first time the function is executed and than use the cashed code on the other calls? (like .NET jit compiler) | Does the python vm compiles method every time? | 1.2 | 0 | 0 | 286 |
4,909,306 | 2011-02-05T19:57:00.000 | 2 | 1 | 0 | 0 | java,python,templates,web-frameworks | 4,909,342 | 4 | false | 1 | 0 | It may sound strange, but there's no need to know "how web development is performed in Python" to start doing it.
In fact, working with language/framework/etc is a single most reliable way to get understanding of it. You won't gain a lot from one-page summaries.
Also, comparing it with Java isn't likely to help. There'... | 2 | 6 | 0 | I am thinking in starting a personal pet web project to experiment with different things and extend my knowledge.
I use Java a lot at work (for web applications :D) and was thinking in making my own in Python since I kinda like this language but never passed the simple scripts stages.
I want to step up a gear regardi... | Python web frameworks vs Java web frameworks (how is web development in Python done?) | 0.099668 | 0 | 0 | 5,940 |
4,909,306 | 2011-02-05T19:57:00.000 | 3 | 1 | 0 | 0 | java,python,templates,web-frameworks | 6,586,407 | 4 | false | 1 | 0 | hi try bottle python framework (bottle.paws.de / bottlepy.org) its really nice to use blistering fast and gets out of your way + the best thing about it is that its one single file to import, i recently migrated from PHP and i have to tell you am so ... loving it! | 2 | 6 | 0 | I am thinking in starting a personal pet web project to experiment with different things and extend my knowledge.
I use Java a lot at work (for web applications :D) and was thinking in making my own in Python since I kinda like this language but never passed the simple scripts stages.
I want to step up a gear regardi... | Python web frameworks vs Java web frameworks (how is web development in Python done?) | 0.148885 | 0 | 0 | 5,940 |
4,909,665 | 2011-02-05T21:09:00.000 | 1 | 0 | 1 | 0 | python | 4,909,772 | 1 | true | 0 | 0 | If you can't use globals, maybe you can use Qt's QThread class. You can use signals to access to the thread. | 1 | 0 | 0 | This might be a silly question, but what's the best way to keep insert/delete/retrieve elements of an array in a multi-threaded Python application, but not keep the array global or assign an entire thread to keep track of the changes to that single array? It feels tiresome to pass the array to each function I use. | Insert/delete/retrieve elements of an array across threads without using globals | 1.2 | 0 | 0 | 228 |
4,909,748 | 2011-02-05T21:23:00.000 | 2 | 0 | 1 | 0 | python,arrays | 4,909,786 | 2 | false | 0 | 0 | In many cases such arrays are not required as there are more elegant solutions to these problems. Explain what you want to do so someone can give some hints.
Anyway, if you really, really need such data structure, use array.array. | 1 | 5 | 1 | Is it possible to create a multi-dimensional array of different types in Python? The way I usually solve it is [([None] * n) for i in xrange(m)], but I don't want to use list. I want something which is really a continuous array of pointers in memory, not a list. (Each list itself is continuous, but when you make a list... | Python: Multi-dimensional array of different types | 0.197375 | 0 | 0 | 5,249 |
4,910,510 | 2011-02-05T23:48:00.000 | 1 | 0 | 0 | 0 | python,algorithm,gps,gis,data-mining | 4,919,289 | 2 | false | 0 | 0 | 1) Extracting trajectories
I think you are in right direction. There are probably will be some noise in gps data, and random walking, you should do some smooth like splines to overcome it.
2) Mining the trajectories
Is there are any business sense in similar trajectories? (This will help build distance metric and th... | 1 | 10 | 1 | I've got 2 questions on analyzing a GPS dataset.
1) Extracting trajectories I have a huge database of recorded GPS coordinates of the form (latitude, longitude, date-time). According to date-time values of consecutive records, I'm trying to extract all trajectories/paths followed by the person. For instance; say from t... | Comparing/Clustering Trajectories (GPS data of (x,y) points) and Mining the data | 0.099668 | 0 | 0 | 6,451 |
4,910,541 | 2011-02-05T23:54:00.000 | 1 | 1 | 0 | 0 | php,python,eclipse,configuration | 4,910,592 | 1 | true | 0 | 0 | you shouldn't have to do anything to eclipse, or any editor, if php\python is installed you can call them from the command line. | 1 | 1 | 0 | I want to run php or python scripts from eclipse that will create folders and files and give them content. I think I know what to write for the php or python code but I am having trouble on what I need to do in eclipse to run my script. I would also like to provide my script with arguments such as folder names through ... | configurations eclipse | 1.2 | 0 | 0 | 132 |
4,910,875 | 2011-02-06T01:14:00.000 | 2 | 0 | 0 | 0 | python,mod-wsgi | 4,922,237 | 1 | false | 1 | 0 | If using embedded mode of mod_wsgi you use WSGIPythonPath directive. If you are using daemon mode, you use the python-path option to the appropriate WSGIDaemonProcess directive.
Ensure you are not using mod_wsgi 1.X and not using mod_python in same Apache. | 1 | 0 | 0 | I installed my django project on Apache web server using mod_wsgi. I used a WSGIScriptAlias directive inside VirtualHost, pointing to a wsgi_handler.py file in my project. It worked fine.
Nevertheless, I had to write inside the wsgi_handler.py something like:
sys.append(absolute_file_path) in order to include some pyt... | Problem with mod_wsgi | 0.379949 | 0 | 0 | 257 |
4,911,289 | 2011-02-06T03:11:00.000 | 0 | 0 | 0 | 0 | python,django,apache,ubuntu,mod-wsgi | 5,279,438 | 3 | true | 1 | 0 | So to wrap this up, we ended up re-installing the OS. I know this is a cop out but it fixed the problem for us.
Thanks for everyone's help! | 2 | 2 | 0 | I am running Apache2 on Ubuntu 9 with python 2.6.2 installed. I get the following error when I try to access a page on my django application:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 42, in load_middleware raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%... | ImproperlyConfigured: Error importing middleware django.middleware.common: "No module named _md5" | 1.2 | 0 | 0 | 6,980 |
4,911,289 | 2011-02-06T03:11:00.000 | 1 | 0 | 0 | 0 | python,django,apache,ubuntu,mod-wsgi | 4,911,387 | 3 | false | 1 | 0 | Try to append to python path you project directory and parent one
sys.path.append('path_to_dynamicuddi_project')
sys.path.append('path_to_dynamicuddi_parent_dir') | 2 | 2 | 0 | I am running Apache2 on Ubuntu 9 with python 2.6.2 installed. I get the following error when I try to access a page on my django application:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 42, in load_middleware raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%... | ImproperlyConfigured: Error importing middleware django.middleware.common: "No module named _md5" | 0.066568 | 0 | 0 | 6,980 |
4,912,128 | 2011-02-06T07:12:00.000 | 0 | 0 | 1 | 0 | python | 4,912,583 | 1 | false | 0 | 0 | The function heapq.heapify from the standard library does this. | 1 | 0 | 0 | In python language:
How to write a function that takes a heap structure (that violates the heap property) and returns None. It changes the array slot in the heap structure so that the heap property is satisfied. | Python programming max heapify? | 0 | 0 | 0 | 400 |
4,914,582 | 2011-02-06T16:35:00.000 | 1 | 1 | 0 | 0 | python,unit-testing | 4,914,696 | 2 | false | 0 | 0 | Not sure what your problem is. The mock class is part of the tests, conceptually at least. It is ok for the tests to depend on particular behaviour of the mock objects that they inject into the code being tested. Of course the injection itself should be shared across unit tests, so that it is easy to change the mockup ... | 2 | 1 | 0 | I'm currently writing a set of unit tests for a Python microblogging library, and following advice received here have begun to use mock objects to return data as if from the service (identi.ca in this case).
However, surely by mocking httplib2 - the module I am using to request data - I am tying the unit tests to a spe... | Using mock objects without tying down unit tests | 0.099668 | 0 | 1 | 223 |
4,914,582 | 2011-02-06T16:35:00.000 | 1 | 1 | 0 | 0 | python,unit-testing | 4,915,281 | 2 | true | 0 | 0 | You are right that if you refactor your library to use something other than httplib2, then your unit tests will break. That isn't such a horrible dependency, since when that time comes it will be a simple matter to change your tests to mock out the new library.
If you want to avoid that, then write a very minimal wrap... | 2 | 1 | 0 | I'm currently writing a set of unit tests for a Python microblogging library, and following advice received here have begun to use mock objects to return data as if from the service (identi.ca in this case).
However, surely by mocking httplib2 - the module I am using to request data - I am tying the unit tests to a spe... | Using mock objects without tying down unit tests | 1.2 | 0 | 1 | 223 |
4,915,202 | 2011-02-06T18:22:00.000 | 0 | 0 | 1 | 0 | python,icons,exe,ico | 4,915,328 | 2 | false | 0 | 1 | do it like this:
If you dont have winrar then install it!
Then right click on your program.exe and select "Add to archive...", under "Archiving options" select "Create SFX Archive". Now go to tab "Advanced" and click on "SFX Options" on "General tab" setup all you need and add "Run after extraction" (yourprogram.exe) u... | 1 | 0 | 0 | How can i set up icon for my existing program.exe and icon.ico ( in the same folder ) using some sort of hidden (settings) file ?
Edit: i am aware of py2exe CustomIcon option, also about WinRar Sfx ...
Question is: it is possible in this specific way i described ? | How to set up icon for a program? | 0 | 0 | 0 | 1,915 |
4,915,361 | 2011-02-06T18:52:00.000 | 120 | 0 | 1 | 0 | python,python-3.x,input | 15,129,556 | 6 | false | 0 | 0 | Python 2:
raw_input() takes exactly what the user typed and passes it back as a string.
input() first takes the raw_input() and then performs an eval() on it as well.
The main difference is that input() expects a syntactically correct python statement where raw_input() does not.
Python 3:
raw_input() was renamed t... | 4 | 390 | 0 | What is the difference between raw_input() and input() in Python 3? | What's the difference between `raw_input()` and `input()` in Python 3? | 1 | 0 | 0 | 347,224 |
4,915,361 | 2011-02-06T18:52:00.000 | 7 | 0 | 1 | 0 | python,python-3.x,input | 30,854,786 | 6 | false | 0 | 0 | I'd like to add a little more detail to the explanation provided by everyone for the python 2 users. raw_input(), which, by now, you know that evaluates what ever data the user enters as a string. This means that python doesn't try to even understand the entered data again. All it will consider is that the entered data... | 4 | 390 | 0 | What is the difference between raw_input() and input() in Python 3? | What's the difference between `raw_input()` and `input()` in Python 3? | 1 | 0 | 0 | 347,224 |
4,915,361 | 2011-02-06T18:52:00.000 | 196 | 0 | 1 | 0 | python,python-3.x,input | 4,915,408 | 6 | false | 0 | 0 | In Python 2, raw_input() returns a string, and input() tries to run the input as a Python expression.
Since getting a string was almost always what you wanted, Python 3 does that with input(). As Sven says, if you ever want the old behaviour, eval(input()) works. | 4 | 390 | 0 | What is the difference between raw_input() and input() in Python 3? | What's the difference between `raw_input()` and `input()` in Python 3? | 1 | 0 | 0 | 347,224 |
4,915,361 | 2011-02-06T18:52:00.000 | 443 | 0 | 1 | 0 | python,python-3.x,input | 4,915,366 | 6 | true | 0 | 0 | The difference is that raw_input() does not exist in Python 3.x, while input() does. Actually, the old raw_input() has been renamed to input(), and the old input() is gone, but can easily be simulated by using eval(input()). (Remember that eval() is evil. Try to use safer ways of parsing your input if possible.) | 4 | 390 | 0 | What is the difference between raw_input() and input() in Python 3? | What's the difference between `raw_input()` and `input()` in Python 3? | 1.2 | 0 | 0 | 347,224 |
4,916,189 | 2011-02-06T21:17:00.000 | 1 | 0 | 0 | 0 | python,colors | 4,916,254 | 3 | false | 0 | 0 | Find the difference between the current color and the target color for each color channel. Calculate your percentage of that difference. Add this to the original value, and you're done.
For example, mixing RGB(255,127,0) with RGB(255,255,255) (white) at 75% gives you RGB(255, 223, 191)
R: 255-255 = 0 * .75 = 0 + 25... | 1 | 0 | 0 | I have a set of colors specified in RBG and CMYK. I want to mix a certain amount of white (given in percent) to these colors. How can I do this based on the representations available? Can someone recommend a package that can help me with this kind of color conversions? | Mixing white to a color | 0.066568 | 0 | 0 | 1,015 |
4,916,890 | 2011-02-06T23:20:00.000 | 3 | 0 | 1 | 0 | javascript,jquery,python,html,django | 4,916,929 | 6 | false | 1 | 0 | Problem in mix of extractions 1st and 2nd level.
Trivial solution...
Build list of possible site suffixes, ordered from narrow to common case.
"co.uk", "uk", "co.jp", "jp", "com"
And check, Can suffix be matched at end of domain. if matched, next part is site. | 2 | 7 | 0 | I have a list of domains e.g.
site.co.uk
site.com
site.me.uk
site.jpn.com
site.org.uk
site.it
also the domain names can contain 3rd and 4th level domains e.g.
test.example.site.org.uk
test2.site.com
I need to try and extract the 2nd level domain, in all these cases being site
Any ideas? :) | Extract 2nd level domain from domain? - Python | 0.099668 | 0 | 0 | 3,869 |
4,916,890 | 2011-02-06T23:20:00.000 | 2 | 0 | 1 | 0 | javascript,jquery,python,html,django | 4,916,933 | 6 | false | 1 | 0 | The only possible way would be via a list with all the top level domains (here like .com or co.uk) possible. Then you would scan through this list and check out. I don't see any other way, at least without accessing the internet at runtime. | 2 | 7 | 0 | I have a list of domains e.g.
site.co.uk
site.com
site.me.uk
site.jpn.com
site.org.uk
site.it
also the domain names can contain 3rd and 4th level domains e.g.
test.example.site.org.uk
test2.site.com
I need to try and extract the 2nd level domain, in all these cases being site
Any ideas? :) | Extract 2nd level domain from domain? - Python | 0.066568 | 0 | 0 | 3,869 |
4,918,867 | 2011-02-07T07:15:00.000 | 2 | 0 | 0 | 0 | python,wsgi | 4,919,128 | 2 | false | 1 | 0 | Isolate the process as a separate daemon, and use MQ or some other IPC to hand it jobs. Have it update a value in a database as it progresses, and read that value in a web page. | 2 | 3 | 0 | I need to start a long running process (30 min) via http and get status as it's running. The "process" is basically a Python script that updates a database. I have the following constraints:
Only one instance of the process can run at a time.
The WSGI application is running in several interpreters, so I can't just mak... | Starting a long running process on a server from a WSGI application | 0.197375 | 0 | 0 | 919 |
4,918,867 | 2011-02-07T07:15:00.000 | 1 | 0 | 0 | 0 | python,wsgi | 4,922,650 | 2 | false | 1 | 0 | Look at using Celery (http://celeryproject.org/) and run the task outside of the Python web application processes. | 2 | 3 | 0 | I need to start a long running process (30 min) via http and get status as it's running. The "process" is basically a Python script that updates a database. I have the following constraints:
Only one instance of the process can run at a time.
The WSGI application is running in several interpreters, so I can't just mak... | Starting a long running process on a server from a WSGI application | 0.099668 | 0 | 0 | 919 |
4,919,133 | 2011-02-07T08:03:00.000 | 1 | 0 | 0 | 0 | python,logging,wsgi | 4,922,546 | 3 | false | 1 | 0 | Direct logging output to sys.stderr. Doing that will see anything logged get routed into the internal Apache logging routines and into the Apache error logs. The way Apache does this works when done from multiple process at the same time. | 1 | 3 | 0 | I have a simple webservice written in Python WSGI, it's running in Apache and modwsgi using the WSGIDaemonProcess processes=4 directive.
How do I add logging? Obviously I can't log to the same file without some sort of mutex, but I don't want performance degraded.
The logging can't block. As far as I know the standard... | How do I do logging in a WSGI application across several processes? | 0.066568 | 0 | 0 | 1,543 |
4,920,471 | 2011-02-07T10:58:00.000 | 5 | 0 | 1 | 0 | python,python-multithreading | 4,921,216 | 3 | false | 0 | 0 | GIL (the Global Interpreter Lock) is just a lock, it does not run anything by itself. Rather, the Python interpreter captures and releases that lock as necessary. As a rule, the lock is held when running Python code, but released for calls to lower-level functions (such as sock.send). As Python threads are real OS-leve... | 1 | 5 | 0 | I have a "I just want to understand it" question..
first, I'm using python 2.6.5 on Ubuntu.
So.. threads in python (via thread module) are only "threads", and is just tells the GIL to run code blocks from each "thread" in a certain period of time and so and so.. and there aren't actually real threads here..
So the ques... | python threads & sockets | 0.321513 | 0 | 1 | 2,910 |
4,924,068 | 2011-02-07T17:01:00.000 | 2 | 0 | 1 | 0 | python,virtualenv,python-idle | 5,899,386 | 9 | false | 0 | 0 | @biomed I am on Windows and I was trying this. In my python2.6 folder I had to copy the python26/tcl/tcl8.5 and python/tcl/tk8.5 folders to python26/Lib and then I created the script above in my virtualenv's scripts folder. Worked great. | 1 | 68 | 0 | I have a package that I installed from a virtual environment. If I just launch the python interpreter, that package can be imported just fine. However, if I launch Idle, that package cannot be imported (since it's only available in one particular virtualenv and not global). How can I launch Idle from a virtualenv, s... | How to launch python Idle from a virtual environment (virtualenv) | 0.044415 | 0 | 0 | 49,942 |
4,924,781 | 2011-02-07T18:08:00.000 | 3 | 0 | 0 | 0 | python | 4,924,807 | 3 | false | 0 | 0 | You could store the state in a temporary file. E.g. write the title into a temporary file if there isn't a temporary file already, and next time read from the file and compare the read title with the new title. | 1 | 3 | 0 | I want to run a Python script every so many minutes. The script starts by fetching the newest article from a rss-feed (using feedparser). What I want, is when the newest article is the same as the last time it ran, the script just ends. How do I accomplish this? | Do nothing if RSS feed hasn't changed | 0.197375 | 0 | 1 | 373 |
4,925,371 | 2011-02-07T19:08:00.000 | 0 | 0 | 1 | 0 | python,regex | 4,925,846 | 5 | false | 0 | 0 | Do the buffering yourself. Load in a chunk, if the regex matches a portion of the chunk, delete the portion from the chunk, carry over unused portion, read the next chunk, repeat.
If the regex is designed to be of a specific theoretical maximum, on the event that nothing matched and the buffer is at leas as big, clear ... | 1 | 2 | 0 | I would like to apply regex to the content of a file without loading the entire file into a string. The RegexObject takes as its first argument a string or a buffer. Is there any way to turn the file into a buffer? | How to apply regex to the content of a file? | 0 | 0 | 0 | 3,301 |
4,927,688 | 2011-02-07T22:59:00.000 | 2 | 1 | 1 | 1 | python,apache | 29,809,235 | 3 | false | 0 | 0 | To use with Python 3, you need to install the right mod_wsgi for python 3.
On Debian or Ubuntu : sudo apt-get install libapache2-mod-wsgi-py3.
For older versions of Python, when installing mod_wsgi, type : ./configure --with-python=/usr/local/bin/python2.5 for version 2.5 for instance. | 3 | 2 | 0 | I have a couple versions of python on my box. My app uses python 2.7 which is found in /usr/local/bin/python. Apache seems to be using an earlier version in /usr/bin/python. How can I configure Apache to use a later version of Python for my app? | Apache Config - Multiple python versions | 0.132549 | 0 | 0 | 2,129 |
4,927,688 | 2011-02-07T22:59:00.000 | 0 | 1 | 1 | 1 | python,apache | 4,928,096 | 3 | false | 0 | 0 | I could be mistaking, but whatever user apache is started with has a profile which likely has the search path in it. You could change the search path to search /usr/local/bin before /usr/bin, though this is not an ideal approach. Whatever default shell is set for the account used by Apache, just check that you have an ... | 3 | 2 | 0 | I have a couple versions of python on my box. My app uses python 2.7 which is found in /usr/local/bin/python. Apache seems to be using an earlier version in /usr/bin/python. How can I configure Apache to use a later version of Python for my app? | Apache Config - Multiple python versions | 0 | 0 | 0 | 2,129 |
4,927,688 | 2011-02-07T22:59:00.000 | 1 | 1 | 1 | 1 | python,apache | 4,927,767 | 3 | true | 0 | 0 | You can't. Either rebuild mod_wsgi against the other version of Python, or change the shebang line in your CGI scripts to the other executable. | 3 | 2 | 0 | I have a couple versions of python on my box. My app uses python 2.7 which is found in /usr/local/bin/python. Apache seems to be using an earlier version in /usr/bin/python. How can I configure Apache to use a later version of Python for my app? | Apache Config - Multiple python versions | 1.2 | 0 | 0 | 2,129 |
4,928,220 | 2011-02-08T00:10:00.000 | 1 | 0 | 0 | 0 | python,mysql,timezone | 4,928,246 | 2 | false | 0 | 0 | It's almost always better to save the time information in UTC, and convert it to local time when needed for presentation and display.
Otherwise, you will go stark raving mad trying to manipulate and compare dates and times in your system because you will have to convert each time to UTC time for comparison and manipula... | 2 | 0 | 0 | I'm storing MySQL DateTimes in UTC, and let the user select their time zone, storing that information.
However, I want to to some queries that uses group by a date. Is it better to store that datetime information in UTC (and do the calculation every time) or is it better to save it in the timezone given? Since time z... | How to handle time zones in a CMS? | 0.099668 | 1 | 0 | 123 |
4,928,220 | 2011-02-08T00:10:00.000 | 3 | 0 | 0 | 0 | python,mysql,timezone | 4,928,244 | 2 | true | 0 | 0 | Generally always store in UTC and convert for display, it's the only sane way to do time differences etc. Or when somebody next year decides to change the summer time dates. | 2 | 0 | 0 | I'm storing MySQL DateTimes in UTC, and let the user select their time zone, storing that information.
However, I want to to some queries that uses group by a date. Is it better to store that datetime information in UTC (and do the calculation every time) or is it better to save it in the timezone given? Since time z... | How to handle time zones in a CMS? | 1.2 | 1 | 0 | 123 |
4,929,075 | 2011-02-08T02:38:00.000 | 6 | 0 | 1 | 0 | python,list-comprehension | 4,929,133 | 2 | true | 0 | 0 | a = sum(e for d in b.itervalues() for e, _ in d) works in Python 2.7.
a = sum([e for d in b.itervalues() for e, _ in d]) works in Python 2.3.
I haven't tried it, but a = sum(e for d in b.values() for e, _ in d) should be the Python 3.0 equivalent. | 2 | 0 | 0 | a = 0
b = {'a': [(1, 'a'), (2, 'b'), (3, 'c')], 'b': [(4, 'd'), (5, 'e')]}
for c, d in b.iteritems():
for e, f in d:
a += e
// now a = 15
Tried several ways. I want to know a way (if possible) to simplify this sum with a list comprehension:
a = sum(...)
Thank you in advance,
pf.me | Is it possible to turn this code snippet in a list comprehension? How? | 1.2 | 0 | 0 | 156 |
4,929,075 | 2011-02-08T02:38:00.000 | 1 | 0 | 1 | 0 | python,list-comprehension | 4,929,153 | 2 | false | 0 | 0 | sum(j for _,i in b.iteritems() for j,_ in i) will do it. | 2 | 0 | 0 | a = 0
b = {'a': [(1, 'a'), (2, 'b'), (3, 'c')], 'b': [(4, 'd'), (5, 'e')]}
for c, d in b.iteritems():
for e, f in d:
a += e
// now a = 15
Tried several ways. I want to know a way (if possible) to simplify this sum with a list comprehension:
a = sum(...)
Thank you in advance,
pf.me | Is it possible to turn this code snippet in a list comprehension? How? | 0.099668 | 0 | 0 | 156 |
4,929,626 | 2011-02-08T04:42:00.000 | 275 | 1 | 1 | 0 | python,cgi,wsgi | 5,120,610 | 4 | false | 0 | 0 | From a totally step-back point of view, Blankman, here is my "Intro Page" for Web Server Gateway Interface:
PART ONE: WEB SERVERS
Web servers serve up responses. They sit around, waiting patiently, and then with no warning at all, suddenly:
a client process sends a request. The client process could be a web server, a ... | 3 | 141 | 0 | Every time I read either WSGI or CGI I cringe. I've tried reading on it before but nothing really has stuck.
What is it really in plain English?
Does it just pipe requests to a terminal and redirect the output? | What are WSGI and CGI in plain English? | 1 | 0 | 0 | 27,805 |
4,929,626 | 2011-02-08T04:42:00.000 | 22 | 1 | 1 | 0 | python,cgi,wsgi | 4,929,678 | 4 | false | 0 | 0 | Both CGI and WSGI define standard interfaces that programs can use to handle web requests. The CGI interface is at a lower level than WSGI, and involves the server setting up environment variables containing the data from the HTTP request, with the program returning something formatted pretty much like a bare HTTP ser... | 3 | 141 | 0 | Every time I read either WSGI or CGI I cringe. I've tried reading on it before but nothing really has stuck.
What is it really in plain English?
Does it just pipe requests to a terminal and redirect the output? | What are WSGI and CGI in plain English? | 1 | 0 | 0 | 27,805 |
4,929,626 | 2011-02-08T04:42:00.000 | 68 | 1 | 1 | 0 | python,cgi,wsgi | 4,929,656 | 4 | true | 0 | 0 | WSGI runs the Python interpreter on web server start, either as part of the web server process (embedded mode) or as a separate process (daemon mode), and loads the script into it. Each request results in a specific function in the script being called, with the request environment passed as arguments to the function.
C... | 3 | 141 | 0 | Every time I read either WSGI or CGI I cringe. I've tried reading on it before but nothing really has stuck.
What is it really in plain English?
Does it just pipe requests to a terminal and redirect the output? | What are WSGI and CGI in plain English? | 1.2 | 0 | 0 | 27,805 |
4,930,216 | 2011-02-08T06:29:00.000 | 0 | 0 | 1 | 1 | python,easy-install | 28,389,353 | 7 | false | 0 | 0 | I know this isn't a direct answer to your question but it does offer one solution to your problem. Python 2.7.9 includes PIP and SetupTools, if you update to this version you will have one solution to your problem. | 1 | 30 | 0 | I have installed Python 2.7.1 on Windows 7, but I am unable to install easy_install.
Please help me. | How to install easy_install in Python 2.7.1 on Windows 7 | 0 | 0 | 0 | 125,598 |
4,930,404 | 2011-02-08T05:07:00.000 | 0 | 0 | 1 | 0 | python,syntax | 4,930,405 | 7 | false | 0 | 0 | Well, you could make your loop go from 0 to 100 with a step the size of 1 which will give you the same amount of steps. Then you can divide i by 100 for whatever you were going to do with it. | 1 | 26 | 0 | I'm trying to loop from 0 to 1 using step sizes of 0.01 (for example). How would I go about doing this? The for i in range(start, stop, step) only takes integer arguments so floats won't work. | How do get more control over loop increments in Python? | 0 | 0 | 0 | 69,186 |
4,931,126 | 2011-02-08T08:53:00.000 | 0 | 1 | 0 | 0 | python,actionscript,cryptography,token,encryption-asymmetric | 4,999,135 | 3 | true | 1 | 0 | After doing some research I have decided to code the part of rsa I need from scratch.
I found some python code that will generate raw integer keys of any length and looked up how the rsa algorithm works.
T^P = X (mod R) to encrypt
X^Q = T (mod R) to decrypt
Where T is the starting data, X is the ending data, P is the p... | 3 | 0 | 0 | I cant seem to find a reliable asymmetric encryption solution to secure data between a python based server application and a client over an open data channel.
I need some way for my client to prevent a man in the middle attack over an open data channel, my current exchange has me sending my clients a token they use to ... | Actionscript Three Asymmetric Encryption | 1.2 | 0 | 0 | 191 |
4,931,126 | 2011-02-08T08:53:00.000 | 0 | 1 | 0 | 0 | python,actionscript,cryptography,token,encryption-asymmetric | 4,947,928 | 3 | false | 1 | 0 | Hardcoding they public keys won't help you, if someone really plans an attack, because the SWF itself is transfered over an unsafe channel, thus the keys can be exchanged just as if they were transmitted individually.
There is basically nothing you can do to prevent man in the middle attacks, you can only make them har... | 3 | 0 | 0 | I cant seem to find a reliable asymmetric encryption solution to secure data between a python based server application and a client over an open data channel.
I need some way for my client to prevent a man in the middle attack over an open data channel, my current exchange has me sending my clients a token they use to ... | Actionscript Three Asymmetric Encryption | 0 | 0 | 0 | 191 |
4,931,126 | 2011-02-08T08:53:00.000 | 0 | 1 | 0 | 0 | python,actionscript,cryptography,token,encryption-asymmetric | 4,947,858 | 3 | false | 1 | 0 | Since decompiling swf content is not a major problem for experienced hackers, I would strongly advise against hardcoding keys. Have you thought about using SSL at all? | 3 | 0 | 0 | I cant seem to find a reliable asymmetric encryption solution to secure data between a python based server application and a client over an open data channel.
I need some way for my client to prevent a man in the middle attack over an open data channel, my current exchange has me sending my clients a token they use to ... | Actionscript Three Asymmetric Encryption | 0 | 0 | 0 | 191 |
4,931,244 | 2011-02-08T09:10:00.000 | 1 | 1 | 0 | 1 | python,bluetooth,ubuntu-10.10 | 4,931,264 | 1 | true | 0 | 0 | Invoke org.bluez.Adapter.SetProperty(u'Name', u'New name here') in the /org/bluez/<pid>/<device> object path on the org.bluez D-Bus bus. | 1 | 0 | 0 | I'm using PyBluez on Ubuntu 10.10. I would like to know how is possible to change the bluetooth name of the local device in software. I couldn't find any command related.. | Change Bluetooth name Python | 1.2 | 0 | 0 | 1,096 |
4,933,190 | 2011-02-08T12:46:00.000 | 2 | 0 | 1 | 0 | python,django,django-views,pickle | 4,933,720 | 3 | false | 1 | 0 | I'd write a python module - a singleton class with an init method that reads the pickled data into a python object, and then whatever 'get' methods you need to get the info out.
Then in your settings.py you just call the initialisation method. Anything that needs to get info from it just imports the module and uses the... | 1 | 3 | 0 | I have a pickle file that contains a list of compiled regexes and other data.
It takes about 1-1.5 seconds to load.
What could a good way of using this list into my views, but have pickle work on the file just once?
Edit:
would importing into settings.py be considered ok?
Any ideas? | Loading a pickled list just once - Django\Python | 0.132549 | 0 | 0 | 1,933 |
4,934,669 | 2011-02-08T15:03:00.000 | 6 | 0 | 0 | 0 | python,image,text,postscript | 4,934,824 | 1 | true | 0 | 0 | It's likely that pgplot drew the fonts in the text directly with lines rather than using text. Especially since pgplot is designed to output to a huge range of devices including plotters where you would have to do this.
Edit:
If you have enough plots to be worth
the effort than it's a very simple
image process... | 1 | 3 | 1 | I want to extract the text information contained in a postscript image file (the captions to my axis labels).
These images were generated with pgplot. I have tried ps2ascii and ps2txt on Ubuntu but they didn't produce any useful results. Does anyone know of another method?
Thanks | Is there a way to extract text information from a postscript file? (.ps .eps) | 1.2 | 0 | 0 | 1,410 |
4,935,257 | 2011-02-08T15:56:00.000 | 1 | 0 | 0 | 1 | python,http,windows-services,scheduled-tasks | 4,955,373 | 3 | false | 0 | 0 | This is trivially easy with a scheduled task which is the native Windows way to schedule tasks! There's no need for cygwin or Python or anything like that.
I have such a task running on my machine which pokes my Wordpress blog every few hours. The script is just a .bat file which calls wget. The task is configured to "... | 2 | 1 | 0 | I need to install on one of my Windows PC's some software that will periodically send a short HTTP POST request to my remote development server. The request is always the same and should get sent every minute.
What would you recommend as the best approach for that?
The things I considered are:
1. Creating a Windows ser... | How to periodically create an HTTP POST request from windows | 0.066568 | 0 | 1 | 2,416 |
4,935,257 | 2011-02-08T15:56:00.000 | 2 | 0 | 0 | 1 | python,http,windows-services,scheduled-tasks | 4,935,443 | 3 | false | 0 | 0 | If you have cygwin, you probably have cron - run a python script from your crontab. | 2 | 1 | 0 | I need to install on one of my Windows PC's some software that will periodically send a short HTTP POST request to my remote development server. The request is always the same and should get sent every minute.
What would you recommend as the best approach for that?
The things I considered are:
1. Creating a Windows ser... | How to periodically create an HTTP POST request from windows | 0.132549 | 0 | 1 | 2,416 |
4,935,387 | 2011-02-08T16:08:00.000 | 1 | 0 | 0 | 1 | python,bash,streaming,video-streaming,multimedia | 4,935,406 | 1 | true | 0 | 0 | what about trying pyffmpeg out. you should be able to get the container info from that. | 1 | 0 | 0 | I have 2 video streams
(1) VLC Generated Compressed MP4 UDP stream
(2) DV Uncompressed UDP Stream
Both are destined to a host. At this Unix receiving host, I would like to detect type of stream coming using Bash or Python Scripting (without tcpdump, I do not have root priv.)
ANY idea guys how to implement ?
Thank you. | Detecting Type of Video Stream | 1.2 | 0 | 0 | 281 |
4,936,524 | 2011-02-08T17:56:00.000 | 0 | 0 | 1 | 0 | python,apache,tomcat,web-scraping,mod-jk | 4,949,650 | 2 | true | 1 | 0 | In order to accomplish what I wanted to do, I just went back to basics. Mechanize is somewhat bulky, and there was a lot of bloat involved in the main functionality tests I had before. So I started with a clean slate and just used cookielib.CookieJar and urllib2 to build a linear test and then run them in a while 1 loo... | 1 | 0 | 0 | We have begun upgrading hardware and software to a 64-bit architecture using Apache with mod_jk and four Tomcat servers (the new hardware). We need to be able to test this equipment with a large number of simultaneous connections while still actually doing things in the app (logging in, etc.)
I currently am using Pytho... | Testing Apache/mod_jk/Tomcat configuration upgrade | 1.2 | 0 | 0 | 361 |
4,937,445 | 2011-02-08T19:34:00.000 | 1 | 0 | 1 | 0 | python | 4,937,510 | 1 | true | 0 | 0 | In Python 3.x, tokenize generates a stream of 5-tuples as its output, just as Python 2.x's generate_tokens does. | 1 | 1 | 0 | In python2.x tokenize() function has two arguments namely, 'readline' and 'tokeneater'. Second argument takes care of the output mechanism for tokenize() and is called once for each token. Now we know that in python3.x second argument 'tokeneater' is not there. How is output mechanism in python3.x being taken care of ? | issue regarding tokenize.py | 1.2 | 0 | 0 | 80 |
4,937,762 | 2011-02-08T20:03:00.000 | 6 | 0 | 0 | 0 | python,django,tdd | 4,937,874 | 3 | false | 1 | 0 | Shouldn't tests test functionality rather than implementation? In other words, test that the field can store an integer, not that it is an IntegerField. Then if that gets changed to a BooleanField your test fails (assuming no coercion), but if it gets changed to a FloatField the test still passes, because it can still ... | 3 | 2 | 0 | If you're trying to do Test Driven Development, is it sane to write tests that check the column type of your models as you write your models?
Like before you write your model, you write a test and say I want an ID field that is an integer field. | TDD django models | 1 | 0 | 0 | 360 |
4,937,762 | 2011-02-08T20:03:00.000 | 7 | 0 | 0 | 0 | python,django,tdd | 4,937,780 | 3 | true | 1 | 0 | I think it's a bit overkill to test the underlying framework within your app testing, in general. Unless you have a suspicion that it isn't well-tested and/or it is something that may change a lot (say you live by developing against trunk), it should be a reasonable assumption that your framework will operate as adver... | 3 | 2 | 0 | If you're trying to do Test Driven Development, is it sane to write tests that check the column type of your models as you write your models?
Like before you write your model, you write a test and say I want an ID field that is an integer field. | TDD django models | 1.2 | 0 | 0 | 360 |
4,937,762 | 2011-02-08T20:03:00.000 | 3 | 0 | 0 | 0 | python,django,tdd | 4,937,956 | 3 | false | 1 | 0 | If you don't want to drive yourself crazy, you should focus on tests that will really help you. Testing that the id column is an integer isn't testing your code, it's testing Django. Even testing that "subject" is a string field isn't helping you much. Test that the models can do what they have to do. | 3 | 2 | 0 | If you're trying to do Test Driven Development, is it sane to write tests that check the column type of your models as you write your models?
Like before you write your model, you write a test and say I want an ID field that is an integer field. | TDD django models | 0.197375 | 0 | 0 | 360 |
4,937,817 | 2011-02-08T20:08:00.000 | 0 | 0 | 0 | 0 | python,mongodb,pymongo | 4,941,686 | 2 | false | 0 | 0 | Does make any sense. The object id is core part of each document. Convert the BSON/JSON document to a native datastructure (depending on your implementation language) and remove _id on this level. Apart from that it does not make much sense what you are trying to accomplish. | 1 | 1 | 0 | I am having problem when I do a query to mongodb using pymongo.
I do not know how to avoid getting the _id for each record.
I am doing something like this,
result = db.meta.find(filters, [
'model',
'fields.parent',
'field... | PYMongo: Keep returning _id in every record after quering, How can I exclude this record? | 0 | 1 | 0 | 803 |
4,938,491 | 2011-02-08T21:10:00.000 | 7 | 0 | 0 | 0 | python,django,django-admin | 61,366,946 | 21 | false | 1 | 0 | Just go to admin.py file and add this line in the file :
admin.site.site_header = "My Administration" | 3 | 254 | 0 | How does one change the 'Django administration' text in the django admin header?
It doesn't seem to be covered in the "Customizing the admin" documentation. | Django Admin - change header 'Django administration' text | 1 | 0 | 0 | 156,772 |
4,938,491 | 2011-02-08T21:10:00.000 | 5 | 0 | 0 | 0 | python,django,django-admin | 62,750,378 | 21 | false | 1 | 0 | You can use these following lines in your main urls.py
you can add the text in the quotes to be displayed
To replace the text Django admin use admin.site.site_header = ""
To replace the text Site Administration use admin.site.site_title = ""
To replace the site name you can use admin.site.index_title = ""
To replace th... | 3 | 254 | 0 | How does one change the 'Django administration' text in the django admin header?
It doesn't seem to be covered in the "Customizing the admin" documentation. | Django Admin - change header 'Django administration' text | 0.047583 | 0 | 0 | 156,772 |
4,938,491 | 2011-02-08T21:10:00.000 | 3 | 0 | 0 | 0 | python,django,django-admin | 4,938,653 | 21 | false | 1 | 0 | You just override the admin/base_site.html template (copy the template from django.contrib.admin.templates and put in your own admin template dir) and replace the branding block. | 3 | 254 | 0 | How does one change the 'Django administration' text in the django admin header?
It doesn't seem to be covered in the "Customizing the admin" documentation. | Django Admin - change header 'Django administration' text | 0.028564 | 0 | 0 | 156,772 |
4,938,556 | 2011-02-08T21:17:00.000 | 5 | 0 | 0 | 0 | python,r,plot,rpy2 | 4,938,599 | 2 | true | 0 | 1 | Plot to a graphics file using jpeg(), png() or another device, then display that file on your wxWidget. | 1 | 3 | 1 | I'm writing a program in Python. The first thing that happens is a window is displayed (I'm using wxPython) that has some buttons and text. When the user performs some actions, a plot is displayed in its own window. This plot is made with R, using rpy2. The problem is that the plot usually pops up on top of the mai... | How do I control where an R plot is displayed, using python and rpy2? | 1.2 | 0 | 0 | 757 |
4,938,738 | 2011-02-08T21:34:00.000 | 0 | 0 | 1 | 0 | python,argparse | 4,938,952 | 3 | false | 0 | 0 | You might consider using fabric for this. | 1 | 0 | 0 | I currently have 2 functions in my .py script.
#1 connects to the database and does some processing.
#2 does some other processing on files
Currently before I run the script, I have to manually comment/uncomment the function I want to run in my main if statement block.
How can I use argparse, so it asks me which functi... | Use argparse to run 1 of 2 functions in my script | 0 | 0 | 0 | 5,676 |
4,939,686 | 2011-02-08T23:24:00.000 | 1 | 0 | 1 | 0 | python-3.x | 4,939,699 | 2 | false | 0 | 0 | There's no way that will work in all environments, so a precise answer might depend on how you are running your top-level Python code. The best thing to do is to put the variables into an object and pass the object to the functions that need it. | 2 | 0 | 0 | Hey, in my python modules (written in python) I want to be able to access the variables from the top level scope, that is, the file that is calling the modules. How would I go about doing this?
Thanks. | Python module get top scope variables | 0.099668 | 0 | 0 | 223 |
4,939,686 | 2011-02-08T23:24:00.000 | 0 | 0 | 1 | 0 | python-3.x | 4,941,659 | 2 | true | 0 | 0 | In general, the way to do this is to provide some API to your plugins (e.g. a module that they import) to provide controlled access to the information they need.
If this information may vary by context, and passing in different arguments to a plugin initialisation function isn't appropriate, then an information API tha... | 2 | 0 | 0 | Hey, in my python modules (written in python) I want to be able to access the variables from the top level scope, that is, the file that is calling the modules. How would I go about doing this?
Thanks. | Python module get top scope variables | 1.2 | 0 | 0 | 223 |
4,940,273 | 2011-02-09T00:45:00.000 | 1 | 0 | 1 | 1 | python,macos,app-store,py2app | 4,971,779 | 6 | false | 0 | 0 | Apple provides the Build Applet tool for Python with Xcode so it should be supported by the App store. MacOS X 10.6.6 includes Python 2.5 and 2.6 as part of the default install, you can specify /usr/bin/python2.5 and /usr/lib/python2.5. | 2 | 49 | 0 | Does Apple accept Python applications for distribution on the new Mac App Store?
If so, how should the application be packaged? Is py2app sufficient? Something else? | Is it possible to deploy a Python application on the Mac App Store? | 0.033321 | 0 | 0 | 14,346 |
4,940,273 | 2011-02-09T00:45:00.000 | 9 | 0 | 1 | 1 | python,macos,app-store,py2app | 4,993,464 | 6 | false | 0 | 0 | I know it's possible because I know of at least one Python-based app that is in the app store ("Pennywise", which is based on my own app, moneyGuru, which uses Python + PyObjc + py2app). I didn't do it myself, so I'm not sure of the details. | 2 | 49 | 0 | Does Apple accept Python applications for distribution on the new Mac App Store?
If so, how should the application be packaged? Is py2app sufficient? Something else? | Is it possible to deploy a Python application on the Mac App Store? | 1 | 0 | 0 | 14,346 |
4,940,449 | 2011-02-09T01:21:00.000 | 20 | 0 | 1 | 0 | python,boto | 4,940,485 | 1 | true | 0 | 0 | If you have pip available: pip install -U boto
If you have easy_install available: easy_install -U boto
Otherwise... install pip. | 1 | 11 | 0 | I am using python's boto script, and I haven't touched in a long time and sort of forgot basic python stuff.
How do I update the script? I'm not even sure how I installed it so please guide me to figure out what I have to do. | How do I update the python lib boto? | 1.2 | 0 | 0 | 11,972 |
4,940,617 | 2011-02-09T02:02:00.000 | 0 | 0 | 1 | 1 | python | 4,940,647 | 6 | false | 0 | 0 | The shell will read the PATH from left to right, so you most likely defined Python 3.1.3 before Python 2.6.6. Specify the full path for each to use both versions. | 3 | 9 | 0 | I have python 2.6.6 and python 3.1.3 currently installed on my machine (Windows Vista 64 bit)
My path variable includes the directory of both versions. How can I specify which python I want to run a program in. For instance, if I want to run a program in python 3, it works but if I want to run a different program in py... | How to run programs in python2 and python3 | 0 | 0 | 0 | 44,324 |
4,940,617 | 2011-02-09T02:02:00.000 | 8 | 0 | 1 | 1 | python | 4,940,652 | 6 | true | 0 | 0 | You can specify the version in the executable name python2.6 and python3. | 3 | 9 | 0 | I have python 2.6.6 and python 3.1.3 currently installed on my machine (Windows Vista 64 bit)
My path variable includes the directory of both versions. How can I specify which python I want to run a program in. For instance, if I want to run a program in python 3, it works but if I want to run a different program in py... | How to run programs in python2 and python3 | 1.2 | 0 | 0 | 44,324 |
4,940,617 | 2011-02-09T02:02:00.000 | 6 | 0 | 1 | 1 | python | 4,940,631 | 6 | false | 0 | 0 | Instead of just typing "python" on the command line, use the full path the python.exe that you want to run: FULL_PATH_TO_PYTHON_2.6.6\python.exe or FULL_PATH_TO_PYTHON_3.1.3\python.exe should distinguish between the two. | 3 | 9 | 0 | I have python 2.6.6 and python 3.1.3 currently installed on my machine (Windows Vista 64 bit)
My path variable includes the directory of both versions. How can I specify which python I want to run a program in. For instance, if I want to run a program in python 3, it works but if I want to run a different program in py... | How to run programs in python2 and python3 | 1 | 0 | 0 | 44,324 |
4,941,125 | 2011-02-09T03:50:00.000 | 0 | 0 | 0 | 0 | python,django,django-models | 4,966,022 | 2 | false | 1 | 0 | It may be more hassle to try to use multiple profiles with the simplistic configuration of UserProfile.
I would suggest using UserProfile with generic foreign key, or completely ditch UserProfile and create separate models with a User foreign key.
If you are going to have a lot of data attached to these extra user pr... | 1 | 2 | 0 | Assuming I have different profiles for different user types - staff, teacher,students:
How do I specify AUTH_PROFILE_MODULE in order to get back the appropriate profile with get_profile? | django how to use AUTH_PROFILE_MODULE with multiple profiles? | 0 | 0 | 0 | 1,474 |
4,941,162 | 2011-02-09T03:56:00.000 | 1 | 0 | 0 | 0 | python,eclipse,matplotlib | 5,640,511 | 1 | true | 0 | 0 | import matplotlib.pyplot as mp
mp.ion()
mp.plot(x,y)
mp.show() | 1 | 1 | 1 | I can draw matplotlib graph in command line(shell) environment, but I find that I could not draw the same graph inside the eclipse IDE. such as plot([1,2,3]) not show in eclipse, I writed show() in the end but still not show anything
my matplotlib use GTKAgg as backend, I use Pydev as plugin of eclipse to develop pyth... | How to draw matplotlib graph in eclipse? | 1.2 | 0 | 0 | 3,911 |
4,941,164 | 2011-02-09T03:57:00.000 | 2 | 0 | 1 | 0 | python,if-statement | 4,941,178 | 7 | false | 0 | 0 | The question is really vague. You could check if x is greater than y in a while loop, or you could use the expression to return a boolean or whatever.
It would be a lot easier to answer if you gave us an example of what you're trying to achieve. | 1 | 3 | 0 | In Python, is it possible to check whether x>y without using the if statement? | Checking if x>y without if statement | 0.057081 | 0 | 0 | 10,018 |
4,946,837 | 2011-02-09T15:21:00.000 | 0 | 0 | 1 | 0 | c++,python,boost-python | 4,959,254 | 2 | true | 0 | 0 | Unfortunately, the standard indexing_suite from Boost.Python does not support std::set. There is a indexing_suite v2, that works on all stl containers. (http://mail.python.org/pipermail/cplusplus-sig/2009-July/014704.html)
It may not have made it to the official distribution, but you can find it by asking around.
(htt... | 2 | 5 | 0 | I have some C++ methods that have std::set<std::string> as argument or return value.
I would like to map this to a Python frozenset (or regular set) but there does not seem to be a straightforward way to do this.
Does anyone know how one may accomplish this task. | Create and access frozenset with Boost Python | 1.2 | 0 | 0 | 741 |
4,946,837 | 2011-02-09T15:21:00.000 | 1 | 0 | 1 | 0 | c++,python,boost-python | 13,380,546 | 2 | false | 0 | 0 | Or you can use std::map<YourType, int> instead of std::set<YourType>, the value can be for example 0. std::map has the same insert/search time complexity as std::set, it also keeps the keys ordered, it will only bloat the memory a little. Then you can use map indexing suite and in python you can hide the difference in ... | 2 | 5 | 0 | I have some C++ methods that have std::set<std::string> as argument or return value.
I would like to map this to a Python frozenset (or regular set) but there does not seem to be a straightforward way to do this.
Does anyone know how one may accomplish this task. | Create and access frozenset with Boost Python | 0.099668 | 0 | 0 | 741 |
4,947,341 | 2011-02-09T16:03:00.000 | 0 | 0 | 0 | 0 | python,pygtk,gtk,gdk | 22,739,002 | 1 | false | 0 | 1 | i just thought of a way
taking half of the color's highest values and taking half of the number directly between them and putting that on the lowest number (Eg: 0,255,255 to 127,255,255 or 0,127,255 to 96,127,255)
or taking the second highest number and the highest number, finding the 50%, putting that as the second h... | 1 | 0 | 0 | I have an image wiht gtk.gdk. I want to make it look grayed out, so I wanna do something like draw a gray rectangle over it with 50% alpha value. How would I do this? The docs are so confusing. | gtk.gdk: make image 50% grayer | 0 | 0 | 0 | 246 |
4,948,509 | 2011-02-09T17:46:00.000 | 1 | 0 | 1 | 1 | python,linux,awk | 4,948,705 | 8 | false | 0 | 0 | Since you need the extra bits the fastest way is to create a set of unique entries (sort -u will do) and then you must compare each entry against each other, e.g.
if x.startswith(y) and not y.startswith(x)
and just leave x and discard y. | 1 | 5 | 0 | I am processing large text files (~20MB) containing data delimited by line.
Most data entries are duplicated and I want to remove these duplications to only keep one copy.
Also, to make the problem slightly more complicated, some entries are repeated with an extra bit of info appended. In this case I need to keep the e... | Removing duplicated lines from a txt file | 0.024995 | 0 | 0 | 7,337 |
4,950,962 | 2011-02-09T21:53:00.000 | 0 | 0 | 0 | 0 | python,django,google-app-engine,django-nonrel | 5,656,577 | 3 | false | 1 | 0 | I have used 'contenttypes, auth and sessions' from 'django.contrib' without any modification, the app code wont cause any problems. However any query using JOINs result in query errors, so you need to write your queries with this limitation in mind.
Did you have a particular app in mind? | 1 | 2 | 0 | Is there a list of django apps that can be used unaltered in django-nonrel or a list of django apps that can be easily adapted to be used in django-nonrel? | Which django apps are directly usable or easily adaptable for django-nonrel? | 0 | 0 | 0 | 198 |
4,953,250 | 2011-02-10T04:06:00.000 | 7 | 1 | 0 | 0 | python,matplotlib,signal-processing,scientific-computing | 4,953,341 | 1 | true | 0 | 0 | There's a ton of ways of doing this. One crude but effective way is to apply a bandpass filter (at 50Hz), thereby eliminating all other signals, and then calculate the RMS power of the last N samples.
Another is you can do a windowed FFT, but not actually FFT - just calculate the bin you want. The window can be whateve... | 1 | 4 | 0 | I'm looking for a good way to estimate the power of a signal (regularly sampled say at 10 kHz) vs. time at just one frequency (say 50 Hz). I could calculate the spectrogram, and then take a slice of it at the target frequency. This seems inefficient though, since I only care about the power at one frequency vs. time.... | how to estimate the (power of a signal at a given frequency) vs. time in python | 1.2 | 0 | 0 | 1,962 |
4,957,545 | 2011-02-10T13:18:00.000 | 1 | 0 | 0 | 0 | python,version | 4,957,642 | 6 | false | 1 | 0 | Go with Python 2.7, especially if you're looking to do Django work or any other web development. Python 3 isn't supported with Django, and most libraries work with the > 2.5 versions of Python. | 3 | 6 | 0 | I've finally decided to start working in Python but there seems to be so many versions out there. I'm mainly interested in web development in Python, so which version should I choose?
I don't know what versions the web frameworks usually support (Django, Pylons and so on) but maybe you guys know? Also, I'd like to know... | Which version of Python should I use for web development? | 0.033321 | 0 | 0 | 893 |
4,957,545 | 2011-02-10T13:18:00.000 | 0 | 0 | 0 | 0 | python,version | 4,958,047 | 6 | false | 1 | 0 | You use the version supported by the web framework of your choice.
That will typically today be Python 2.6 or 2.7. | 3 | 6 | 0 | I've finally decided to start working in Python but there seems to be so many versions out there. I'm mainly interested in web development in Python, so which version should I choose?
I don't know what versions the web frameworks usually support (Django, Pylons and so on) but maybe you guys know? Also, I'd like to know... | Which version of Python should I use for web development? | 0 | 0 | 0 | 893 |
4,957,545 | 2011-02-10T13:18:00.000 | 0 | 0 | 0 | 0 | python,version | 4,957,702 | 6 | false | 1 | 0 | If you want to use shared hosters than you should use Version 2.5, because the most of them only have 2.5 (at least in my country). And if you want to use a newer version of Python, 2.7 is compatible to 2.5. | 3 | 6 | 0 | I've finally decided to start working in Python but there seems to be so many versions out there. I'm mainly interested in web development in Python, so which version should I choose?
I don't know what versions the web frameworks usually support (Django, Pylons and so on) but maybe you guys know? Also, I'd like to know... | Which version of Python should I use for web development? | 0 | 0 | 0 | 893 |
4,959,741 | 2011-02-10T16:20:00.000 | 0 | 0 | 1 | 0 | python,printing,tcp | 53,659,561 | 6 | false | 0 | 0 | s=b'\x04NZ\xdf\x7f\xab'
1)
import struct
ssid_2 = "%02x:%02x:%02x:%02x:%02x:%02x" % struct.unpack("BBBBBB", s)
or
2)
':'.join(f'{x:02x}' for x in s)
but 1) is way faster than 2) | 1 | 7 | 0 | I have mac address in 6 byte string. How would you print it in "human" readable format?
Thanks | Python. Print mac address out of 6 byte string | 0 | 0 | 0 | 12,640 |
4,961,707 | 2011-02-10T19:32:00.000 | 1 | 1 | 0 | 0 | python,cx-oracle | 5,087,119 | 1 | true | 0 | 0 | Using try ... except is a perfectly suitable way to do this kind of detection. The same technique is used to write portable apps using SQLITE that will work on newer 2.7 Python with SQLITE in the library and older 2.4 where SQLITE was an addon module with a more cryptic name. | 1 | 1 | 0 | I have a custom module that's basically a thin wrapper around a database connection with cx_Oracle. I'd like to re-use this module on computers with both the unicode version of cx_Oracle installed, and with the non-unicode version.
To do this, I need to "detect" the version installed. I could "try" making a connect... | Is this the preferred way to detect if the unicode or non-unicode version of cx_oracle was installed? | 1.2 | 0 | 0 | 227 |
4,961,951 | 2011-02-10T19:56:00.000 | 24 | 0 | 0 | 0 | python,django | 4,961,970 | 3 | true | 1 | 0 | you mean python manage.py shell ? | 2 | 4 | 0 | In django, can you load a django app into the python interpreter like in rails?
i.e. does django have: irb
? | In django, can you load a django app into the python interpreter like in rails? | 1.2 | 0 | 0 | 3,150 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.