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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7,297,217 | 2011-09-04T03:21:00.000 | 2 | 0 | 1 | 0 | python,google-app-engine,math | 7,297,252 | 2 | true | 0 | 0 | There are many ways that you could do this. Try this for example, let F-A be 0-11 (you can make your own; however try to take difficulty into account), so each score is one higher than the previous. For every game you play, you receive a score (from 0-11). Create a total score and add the game score every time to the t... | 1 | 2 | 0 | I need to create a function/method ( in python) which calculates a high score "leaderboard". Each player will have played any number of rounds of the game, recieving a score for each round. I want to know what's the best way to sort the top ranking players (accounting for score AND number of rounds played). The possibl... | Calculating a game's high score table | 1.2 | 0 | 0 | 1,246 |
7,297,507 | 2011-09-04T05:06:00.000 | 3 | 0 | 0 | 0 | python,qt,pyqt,qtreewidget | 7,299,389 | 2 | true | 0 | 1 | Yes using the MVC facilities is the way to go ...
Even though you are using QTreeWidget you are still working with a class derived from QAbstractItemView therefore the model() and setModel() calls are available. Take a model from one of the widgets that you are creating and then set it in the other widgets. Whenever yo... | 2 | 2 | 0 | I'm new to Python and PyQt. What is the best way to keep 4 QtTreeWidgets synchronized so that the items are the same as well as all the attributes of all the items? These widgets appear in different dialog boxes at different times during a session. For a number of reasons, I need to keep as much of the existing code, s... | Synchronized Qt TreeWidgets | 1.2 | 0 | 0 | 451 |
7,297,507 | 2011-09-04T05:06:00.000 | 0 | 0 | 0 | 0 | python,qt,pyqt,qtreewidget | 7,298,076 | 2 | false | 0 | 1 | I'm sure you're right that using Model/View is the best approach.
But without an idea of roughly how many items your tree widgets will have, and how frequently they'll be updated, it's hard to weigh up alternative approaches. Also, what version of Qt are you using?
If the number of updates and items are not huge, one a... | 2 | 2 | 0 | I'm new to Python and PyQt. What is the best way to keep 4 QtTreeWidgets synchronized so that the items are the same as well as all the attributes of all the items? These widgets appear in different dialog boxes at different times during a session. For a number of reasons, I need to keep as much of the existing code, s... | Synchronized Qt TreeWidgets | 0 | 0 | 0 | 451 |
7,297,719 | 2011-09-04T06:22:00.000 | 5 | 1 | 1 | 0 | python,unit-testing | 7,297,727 | 4 | true | 0 | 0 | Test logic and tests should never be part of "production" (production can mean in use by you, released to client, etc.) code. So, it is a bad idea to have them anywhere within your script.
Ideally, have them in separate files. | 3 | 10 | 0 | When you write some scripts that are self sufficient, is it a bad idea to use the if __name__ == '__main__' as a place to write tests? | Use if __name__ == '__main__': for tests | 1.2 | 0 | 0 | 2,066 |
7,297,719 | 2011-09-04T06:22:00.000 | 0 | 1 | 1 | 0 | python,unit-testing | 7,297,726 | 4 | false | 0 | 0 | I guess not, in fact, I saw a lot of python scripts (mostly plugins of another application) written that way. | 3 | 10 | 0 | When you write some scripts that are self sufficient, is it a bad idea to use the if __name__ == '__main__' as a place to write tests? | Use if __name__ == '__main__': for tests | 0 | 0 | 0 | 2,066 |
7,297,719 | 2011-09-04T06:22:00.000 | 3 | 1 | 1 | 0 | python,unit-testing | 7,297,763 | 4 | false | 0 | 0 | Best practice is to put the tests in separate units that use the unittest module. This separation allows you to keep the main code clean (no need for lots of testing helper functions) and encourages you to write good comprehensive tests since you are not inhibited by cluttering the main code. | 3 | 10 | 0 | When you write some scripts that are self sufficient, is it a bad idea to use the if __name__ == '__main__' as a place to write tests? | Use if __name__ == '__main__': for tests | 0.148885 | 0 | 0 | 2,066 |
7,299,808 | 2011-09-04T14:21:00.000 | 1 | 0 | 1 | 0 | python,argparse | 7,299,861 | 1 | true | 0 | 0 | If you have a list [(key, value), (key, value), ...], you can turn it into a dict with that_dict = dict(that_list). Then you can unpack it into set_defaults, i.e. parser.set_default(**that_dict). | 1 | 0 | 0 | I am trying to use ArgumentParser.set_defaults from argparse. I want a keyworded tuple like this: parser.set_defaults(bar=42, baz='badger')
I have the item from the output of ConfigParser.items which is: ('baz','badger').
How do I convert this into the keyworded tuple that set_defaults is expecting? | How to build a keyworded tuple? | 1.2 | 0 | 0 | 126 |
7,300,321 | 2011-09-04T15:42:00.000 | 0 | 0 | 1 | 0 | python,download,pip,zip | 62,803,853 | 8 | false | 1 | 0 | I would prefer (RHEL) - pip download package==version --no-deps --no-binary=:all: | 3 | 144 | 0 | If I want to use the pip command to download a package (and its dependencies), but keep all of the zipped files that get downloaded (say, django-socialregistration.tar.gz) - is there a way to do that?
I've tried various command-line options, but it always seems to unpack and delete the zipfile - or it gets the zipfile,... | How to use Python's pip to download and keep the zipped files for a package? | 0 | 0 | 0 | 173,682 |
7,300,321 | 2011-09-04T15:42:00.000 | 9 | 0 | 1 | 0 | python,download,pip,zip | 48,927,464 | 8 | false | 1 | 0 | Use pip download <package1 package2 package n> to download all the packages including dependencies
Use pip install --no-index --find-links . <package1 package2 package n> to install all the packages including dependencies.
It gets all the files from CWD.
It will not download anything | 3 | 144 | 0 | If I want to use the pip command to download a package (and its dependencies), but keep all of the zipped files that get downloaded (say, django-socialregistration.tar.gz) - is there a way to do that?
I've tried various command-line options, but it always seems to unpack and delete the zipfile - or it gets the zipfile,... | How to use Python's pip to download and keep the zipped files for a package? | 1 | 0 | 0 | 173,682 |
7,300,321 | 2011-09-04T15:42:00.000 | 3 | 0 | 1 | 0 | python,download,pip,zip | 60,539,440 | 8 | false | 1 | 0 | installing python packages offline
For windows users:
To download into a file
open your cmd and folow this:
cd <*the file-path where you want to save it*>
pip download <*package name*>
the package and the dependencies will be downloaded in the current working directory.
To install from the current working directory:
se... | 3 | 144 | 0 | If I want to use the pip command to download a package (and its dependencies), but keep all of the zipped files that get downloaded (say, django-socialregistration.tar.gz) - is there a way to do that?
I've tried various command-line options, but it always seems to unpack and delete the zipfile - or it gets the zipfile,... | How to use Python's pip to download and keep the zipped files for a package? | 0.07486 | 0 | 0 | 173,682 |
7,300,903 | 2011-09-04T17:25:00.000 | 3 | 1 | 0 | 0 | python,performance,algorithm,optimization,code-readability | 7,301,095 | 4 | false | 0 | 0 | Yours is a very good question that arises in almost every piece of code, however simple or complex, that's written by any programmer who wants to call himself a pro.
I try to remember and keep in mind that a reader newly come to my code has pretty much the same crude view of the problem and the same straightforward (m... | 1 | 18 | 1 | I am writing a scientific program in Python and C with some complex physical simulation algorithms. After implementing algorithm, I found that there are a lot of possible optimizations to improve performance. Common ones are precalculating values, getting calculations out of cycle, replacing simple matrix algorithms wi... | Preserve code readability while optimising | 0.148885 | 0 | 0 | 434 |
7,301,681 | 2011-09-04T19:41:00.000 | 2 | 1 | 0 | 0 | python,django,unit-testing,testing,django-testing | 7,301,849 | 1 | true | 1 | 0 | Yes, Django unit tests, using the Client feature, are capable of testing whether or not your routes and forms are correct.
If you want full-blown behavior-driven testing from the outside, you can used a BDD framework like Zombie.
As for which tests you need, Django author Jacob Kaplan-Moss answered the question suc... | 1 | 4 | 0 | Let's says I have a Djano app. Users can sign up, get a activation mail, activate their accounts and log in. After logging in, users can can create, update and delete objects rhough a custom Form which uses the Manager to handle the Model.
What should I be testing here — should I use the request framework to make reque... | What kind of tests should one write in Django | 1.2 | 0 | 0 | 288 |
7,302,450 | 2011-09-04T22:12:00.000 | 1 | 0 | 1 | 1 | python,io,stdout | 7,310,072 | 1 | true | 0 | 0 | The answer is: you cannot tell (not without serious uglyness, an external C module or similar).
The reason is that python’s file-implementation is based on the C (stdio) implementation for FILE *. So an underlying python file object basically just has a reference to the opened FILE. When writing data the C-implementati... | 1 | 5 | 0 | I'm trying to debug some code I wrote, which involves a lot of parallel processes. And have some unwanted behaviour involving output to sys.stdout and certain messages being printed twice. For debugging purposes it would be very useful to know whether at a certain point sys.stdout has been flushed or not. I wonder if t... | How to tell whether sys.stdout has been flushed in Python | 1.2 | 0 | 0 | 431 |
7,303,309 | 2011-09-05T02:02:00.000 | 1 | 0 | 0 | 0 | javascript,python,http,foursquare | 7,354,603 | 2 | false | 0 | 0 | The current API limits results to 50. You should try altering your coordinates to be more precise to avoid not finding your venue.
Pagination would be nice but 50 is a lot of venues for a search. | 1 | 1 | 0 | I am trying to get some locations in New York using FourSquare API using the following API call:
https://api.foursquare.com/v2/venues/search?ll=40.7,-74&limit=50
What I don't understand is that if the call imposes a limit of 50 search results (which is the maximum), how can I get more locations? When using Facebook A... | How do I get more locations? | 0.099668 | 0 | 1 | 2,222 |
7,305,455 | 2011-09-05T08:16:00.000 | 0 | 0 | 1 | 1 | python,windows,directory | 7,305,485 | 2 | false | 0 | 0 | Why don't you have the folder(s) zipped & unzip the folder when ever the game loads (into temp folder), from there things would be simpler. since the data is in temp, you can delete the information when the program exits or let windows clean it up.
this suggestion would work if the folder size is relatively small (a f... | 2 | 1 | 0 | I am working on a mod script in Python for a legacy game. This game looks for the folder "AI" in its installation directory. Now, everytime before the game runs, a certain folder is chosen (say, AI_1 or AI_2), which should behave as if it is the AI folder (the actual AI folder doesn't exist).
I thought of a few solutio... | Redirecting one directory to another | 0 | 0 | 0 | 106 |
7,305,455 | 2011-09-05T08:16:00.000 | 0 | 0 | 1 | 1 | python,windows,directory | 7,305,874 | 2 | true | 0 | 0 | I think that option with renaming is fine. To workaround a situation when scrip is terminated unexpectedly put an additional file with original folder name to all of the AI_x folders. Then on startup just check this file in AI folder and rename the folder back to its original name.
Another variant is to add only one fi... | 2 | 1 | 0 | I am working on a mod script in Python for a legacy game. This game looks for the folder "AI" in its installation directory. Now, everytime before the game runs, a certain folder is chosen (say, AI_1 or AI_2), which should behave as if it is the AI folder (the actual AI folder doesn't exist).
I thought of a few solutio... | Redirecting one directory to another | 1.2 | 0 | 0 | 106 |
7,307,191 | 2011-09-05T11:12:00.000 | 0 | 0 | 0 | 0 | python,numpy,fortran,scipy,scientific-computing | 7,308,174 | 4 | false | 0 | 0 | If you have Mathematica, it can import LaTeX code to a Mathematica expression, which can then be exported to C or MATLAB code, possibly FORTRAN as well.
It is fairly simple to convert MATLAB to Python syntax, I've done it in the past by search-and-replace, but a simple script could probably do it even quicker. | 1 | 12 | 0 | I am writing a code which had long mathematical equations with many trigonometric and other identities. Is there a way of visualising the same expression in latex and making a C or python expression from it or the other way around.
How do you enter and check mathematical expressions to see if the brackets etc are in th... | Methods for entering equations while programming in C/C++ , Python or Fortran | 0 | 0 | 0 | 1,600 |
7,307,423 | 2011-09-05T11:30:00.000 | 1 | 0 | 0 | 0 | java,python,xml,sax,stax | 7,309,549 | 1 | false | 1 | 0 | The Java approach seems to be that either you get streaming or DOM parser but not both; while python allows mixing the two. | 1 | 0 | 0 | StAX seems to be a pulling parser (like SAX but without inversion of control). But I didn't find the equivalent of python's expandNode which is what I was interested in in the first place, I don't care about inversion of control.
For those who don't know pulldom, it's a S(t)AX parser where at any point you can obtain t... | Is there an equivalent of python's pulldom for java? | 0.197375 | 0 | 1 | 180 |
7,311,676 | 2011-09-05T18:40:00.000 | 1 | 1 | 0 | 0 | python,monkeyrunner | 8,291,126 | 1 | false | 0 | 1 | Monkeyrunner use Jython as its Python interface (jython.jar under tools\lib folder).
It uses 2.5.0 version. Now the latest Jython version is 2.5.2.
Either one does not support pywin32 or any other modules. It only supports standard Python modules in version 2.5. | 1 | 4 | 0 | I am using MonkeyRunner to automate some UI test cases.
I need to collect logs from the device using tool like QXDM.
I see that win32com python module can be used to launch QXDM and collecting logs.
But when i use from win32com.client import Dispatch in python script which is passed as argument to MonkeyRunner, MonkeyR... | MonkeyRunner::How to install python modules? | 0.197375 | 0 | 0 | 2,667 |
7,312,374 | 2011-09-05T20:14:00.000 | 3 | 0 | 1 | 0 | python,django-haystack | 18,619,990 | 5 | false | 1 | 0 | I had ran pip install haystack and got this error, then I ran pip install django-haystack problem solved! | 4 | 16 | 0 | I am pretty stuck right now. I have a Django project that's been working great until I tried to add Haystack/Whoosh for search. I've had this same stack in other projects working fine.
Whenever I have "haystack" in my settings.INSTALLED_APPS and I try manage.py runserver or manage.py shell I get 'Error: cannot import n... | Haystack in INSTALLED_APPS results in Error: cannot import name openProc | 0.119427 | 0 | 0 | 4,169 |
7,312,374 | 2011-09-05T20:14:00.000 | 17 | 0 | 1 | 0 | python,django-haystack | 7,312,455 | 5 | false | 1 | 0 | It turns out I was able to get it working by installing the latest source code using pip install git+git://github.com/toastdriven/django-haystack.git
Something was wrong with the version I got doing pip install haystack | 4 | 16 | 0 | I am pretty stuck right now. I have a Django project that's been working great until I tried to add Haystack/Whoosh for search. I've had this same stack in other projects working fine.
Whenever I have "haystack" in my settings.INSTALLED_APPS and I try manage.py runserver or manage.py shell I get 'Error: cannot import n... | Haystack in INSTALLED_APPS results in Error: cannot import name openProc | 1 | 0 | 0 | 4,169 |
7,312,374 | 2011-09-05T20:14:00.000 | 0 | 0 | 1 | 0 | python,django-haystack | 10,380,456 | 5 | false | 1 | 0 | Installing a past version with pip install haystack==0.10 worked for me, but I think when I have time I'm going to try to migrate to Haystack 2.0. | 4 | 16 | 0 | I am pretty stuck right now. I have a Django project that's been working great until I tried to add Haystack/Whoosh for search. I've had this same stack in other projects working fine.
Whenever I have "haystack" in my settings.INSTALLED_APPS and I try manage.py runserver or manage.py shell I get 'Error: cannot import n... | Haystack in INSTALLED_APPS results in Error: cannot import name openProc | 0 | 0 | 0 | 4,169 |
7,312,374 | 2011-09-05T20:14:00.000 | 1 | 0 | 1 | 0 | python,django-haystack | 22,312,453 | 5 | false | 1 | 0 | I had this issue as well, and noticed it was because I had the old config vars in settings.py - namely HAYSTACK_SITECONF. Once it was removed, the error went away. | 4 | 16 | 0 | I am pretty stuck right now. I have a Django project that's been working great until I tried to add Haystack/Whoosh for search. I've had this same stack in other projects working fine.
Whenever I have "haystack" in my settings.INSTALLED_APPS and I try manage.py runserver or manage.py shell I get 'Error: cannot import n... | Haystack in INSTALLED_APPS results in Error: cannot import name openProc | 0.039979 | 0 | 0 | 4,169 |
7,313,004 | 2011-09-05T21:45:00.000 | 3 | 0 | 1 | 0 | .net,python,ironpython | 7,317,306 | 2 | false | 0 | 1 | I use IronPython\Tools\Scripts\pyc.py to create .exe and then xcopy deployment instead of installer. | 2 | 2 | 0 | I'm not using sharpdevelop or visual studio for ironpython app development. I have my reasons for not using them for app development. What are my console based options for compiling ironpython .exe file and packaging it manually ?
Is it possible to create executable app with ironpython and pack it using installer ? | Packing ironpython app into .exe and Installer | 0.291313 | 0 | 0 | 653 |
7,313,004 | 2011-09-05T21:45:00.000 | 1 | 0 | 1 | 0 | .net,python,ironpython | 7,324,311 | 2 | true | 0 | 1 | I've used pyc and InnoSetup to create my installers. You can also download and run WIX from the command line without using #Develop or Visual Studio. The key is make sure you include all of the DLL's you need and to NGEN them on install for shorter start times and better performance. | 2 | 2 | 0 | I'm not using sharpdevelop or visual studio for ironpython app development. I have my reasons for not using them for app development. What are my console based options for compiling ironpython .exe file and packaging it manually ?
Is it possible to create executable app with ironpython and pack it using installer ? | Packing ironpython app into .exe and Installer | 1.2 | 0 | 0 | 653 |
7,313,761 | 2011-09-06T00:08:00.000 | -9 | 0 | 1 | 0 | python,asynchronous,twisted,addition,arithmetic-expressions | 20,604,305 | 3 | false | 0 | 0 | Good question, and Twisted (or Python) should have a way to at least spawn "a + b" of to several cores (on my 8 core i7).
Unfortunately the Python GIL prevents this from happening, meaning that you will have to wait, not only for the CPU bound task, but for one core doing the job, while the seven others core are doing... | 1 | 48 | 0 | I have two integers in my program; let's call them "a" and "b". I would like to add them together and get another integer as a result. These are regular Python int objects. I'm wondering; how do I add them together with Twisted? Is there a special performAsynchronousAddition function somewhere? Do I need a Deferre... | How do I add two integers together with Twisted? | -1 | 0 | 0 | 5,861 |
7,313,898 | 2011-09-06T00:32:00.000 | 1 | 0 | 1 | 0 | python,multithreading,semaphore | 7,313,916 | 1 | true | 0 | 0 | #1: Yes, it's safe to abandon the semaphore with a non-zero count. It's just a value after all.
#2: It's nicer to reduce the amount of code. Strive to write the minimum amount of clear code for a correct implementation. | 1 | 2 | 0 | I'm using a semaphore to hand work off to another thread in Python. I.e. the master thread will put an item on a queue, then call the semaphore's release method; the worker thread will call acquire on the semaphore, then pop an item off the queue to work on.
There's also a special TERMINATE item that the master can pu... | Cleanup of semaphore in Python | 1.2 | 0 | 0 | 3,291 |
7,315,126 | 2011-09-06T05:00:00.000 | 3 | 0 | 0 | 0 | android,c++,python,ios | 7,315,189 | 3 | true | 0 | 1 | What would you recommend for someone who has a background in python
and C++?
Android uses Java as the main programming language, iOS uses Objective-C.
IMHO Java is easier to learn and more consistent compared to Obj-C.
Is developing for the honeycomb os for tablets pretty much the same as
android development?
H... | 3 | 0 | 0 | I've been wanting to get into mobile/tablet app development but I'm not sure whether to go with iOS or Android. Here are a few specific questions I had:
What would you recommend for someone who has a background in python and C++?
Is developing for the honeycomb os for tablets pretty much the same as android develop... | choosing between android and iOS for a programming novice | 1.2 | 0 | 0 | 882 |
7,315,126 | 2011-09-06T05:00:00.000 | 1 | 0 | 0 | 0 | android,c++,python,ios | 7,315,249 | 3 | false | 0 | 1 | To be honest, your current skill set is insufficient for neither Android nor iOS. So, it doesn't matter which platform you decide. Either way, you will have some deep learning curve. However, you could write code in C++ for Android and iOS.
I'm not aware that Python supports both iOS and Android. There're a dozen of fr... | 3 | 0 | 0 | I've been wanting to get into mobile/tablet app development but I'm not sure whether to go with iOS or Android. Here are a few specific questions I had:
What would you recommend for someone who has a background in python and C++?
Is developing for the honeycomb os for tablets pretty much the same as android develop... | choosing between android and iOS for a programming novice | 0.066568 | 0 | 0 | 882 |
7,315,126 | 2011-09-06T05:00:00.000 | 2 | 0 | 0 | 0 | android,c++,python,ios | 7,315,444 | 3 | false | 0 | 1 | What would you recommend for someone who has a background in python and C++?
I would recommend going for android development. As Android is an open source OS, in future more devices will have it installed for its cost effectiveness. Android development needs you to learn java, which unlike objective-C, will not restri... | 3 | 0 | 0 | I've been wanting to get into mobile/tablet app development but I'm not sure whether to go with iOS or Android. Here are a few specific questions I had:
What would you recommend for someone who has a background in python and C++?
Is developing for the honeycomb os for tablets pretty much the same as android develop... | choosing between android and iOS for a programming novice | 0.132549 | 0 | 0 | 882 |
7,315,212 | 2011-09-06T05:13:00.000 | 2 | 0 | 0 | 1 | python,streaming,subprocess,producer-consumer | 7,316,014 | 3 | false | 0 | 0 | Well I am new to python, but it seems proc.communicate or proc.stdout.readline/readlines waits till the process has completed.
As per my knowledge, you can implement a rotational logging and redirect output to a file, then using subprocess you can fire tailf -n XX logfile, in a loop until the program ends, and print th... | 1 | 2 | 0 | I have a subprocess which is constantly producing data, but most of the data I'm not interested in. However occasionally, at random times, I need to grab a sample of the output - the thing is I need to read it at well defined boundaries. For example, let's assume the process produces a constant 100 bytes per second a... | Python communicate with a subprocess | 0.132549 | 0 | 0 | 1,058 |
7,322,299 | 2011-09-06T15:24:00.000 | 5 | 0 | 1 | 0 | python,multithreading,object,global | 7,325,389 | 1 | true | 1 | 0 | If you don't want to lock, then either don't use globals, or use thread-local storage (in a webapp, you can be fairly sure that a request won't cross thread boundary). If global state can be avoided, it should be avoided. This makes multi-threading way easier to implement and debug.
I also disagree that passing objects... | 1 | 3 | 0 | After reading a lot on this subject and discussing on IRC, the response seems to be: stay away from threads. Sorry for repeating this question, my intention is to go deeper in the subject by not accepting the "threading is evil" answer, with the hope to find a common solution.
EDIT: Just Say No to the combined evils of... | Pythonic thread-safe object | 1.2 | 0 | 0 | 1,682 |
7,323,906 | 2011-09-06T17:40:00.000 | 1 | 0 | 1 | 0 | python,string,list,python-2.7 | 7,323,960 | 6 | false | 0 | 0 | You could place all the strings in a text file, one string on each line. Then strings = list(open("datafile", "r")). | 2 | 5 | 0 | I am new to python and essentially trying to figure out the syntax that replicates this functionality: strings = ["foo", "bar", "apple"] with something similar to strings = [foo, bar, apple] so that I don't have to put quotes around all the entries. Thanks! | Python: efficient syntax for creating a list composed of strings | 0.033321 | 0 | 0 | 204 |
7,323,906 | 2011-09-06T17:40:00.000 | 1 | 0 | 1 | 0 | python,string,list,python-2.7 | 7,324,018 | 6 | false | 0 | 0 | I would say that there is no easier way to create a list of strings than what you're already doing.
As other answers have pointed out, there are ways to put all the strings in one big string or file, then split them, but in my opinion that is more difficult to type than the quotes, particularly if you have a decent IDE... | 2 | 5 | 0 | I am new to python and essentially trying to figure out the syntax that replicates this functionality: strings = ["foo", "bar", "apple"] with something similar to strings = [foo, bar, apple] so that I don't have to put quotes around all the entries. Thanks! | Python: efficient syntax for creating a list composed of strings | 0.033321 | 0 | 0 | 204 |
7,327,182 | 2011-09-06T23:07:00.000 | 0 | 1 | 0 | 0 | javascript,python,html,mechanize | 9,391,655 | 1 | false | 1 | 0 | Mechanize doesn't deal with Javascript. It only take care of HTML. So you can't stop Javascript running using Mechanize. You need to find some other solution. | 1 | 5 | 0 | I don't know why, but I cant find it anywhere. All i need is the command to disable javascript in python's mechanize. | How do you disable javascript in python's mechanize? | 0 | 0 | 0 | 663 |
7,328,338 | 2011-09-07T02:40:00.000 | -1 | 0 | 0 | 0 | python,qt,user-interface,wxpython,pyqt4 | 56,841,168 | 4 | false | 0 | 1 | All these tools are light years behind Delphi or Lazarus in Pascal world. The sad truth is that there is no real RAD GUI tools comparable to Delphi in Python world. | 1 | 12 | 0 | I was hoping to find a tool similar to Borland Delphi or VisualBasic for Python. Basically, I want to be able to program Windows apps with ease, without actually having to code every single widget. Does such a software exist? Thanks! | WYSIWYG tool for programming GUI in Python? | -0.049958 | 0 | 0 | 13,231 |
7,328,959 | 2011-09-07T04:46:00.000 | 4 | 0 | 0 | 1 | python,google-app-engine,pydev | 7,329,481 | 1 | true | 1 | 0 | The dev_appserver and the production environment don't have any concept of projects or libraries, so you need to structure your app so that all the necessary libraries are under the application's root. The easiest way to do this, usually, is to symlink them in as subdirectories, or worst-case, to copy them (or, using v... | 1 | 5 | 0 | it's a couple of months I've started development in Python - having myself a C# and Java background.
I'm currently working on 2 different python/appengine applications, and as often happens in those cases, both application share common code - so I would like to refactor and move the common/generic code into a shared pl... | Referencing an external library in a Python appengine project, using Pydev/Eclipse | 1.2 | 0 | 0 | 979 |
7,330,279 | 2011-09-07T07:30:00.000 | 0 | 1 | 1 | 0 | c++,python,interface | 7,330,536 | 2 | false | 0 | 1 | Why do you say that all functions called by Python have to be
static? It's usual for that to be the case, in order to avoid
name conflicts (since any namespace, etc. will be ignored
because of the extern "C"), but whether the function is static
or not is of no consequence.
When interfacing a library in C++, in my e... | 1 | 0 | 0 | I am writing a python interface to a c++ library and am wondering about the correct design of the library.
I have found out (the hard way) that all methods passed to python must be declared static. If I understand correctly, this means that all functions basically must be defined in the same .cpp file. My interface has... | What is the pythonic structure of the code of a python-c++ interface with many functions? | 0 | 0 | 0 | 61 |
7,332,758 | 2011-09-07T11:01:00.000 | 0 | 1 | 0 | 0 | java,php,.net,python,ruby | 7,332,862 | 4 | false | 1 | 0 | For rapid prototyping the more dynamic the language the better. Something like excel is a good for rapid prototyping. You can have a formula and a graph with a dozen clicks.
However in the long run you may need to migrate your system to something more enterprise friendly. This doesn't always mean you should start thi... | 1 | 0 | 0 | Many people say developing in Python, Ruby, PHP ...etc is much faster than Java.
Question is, why? In terms of coding, IDEs, available libraries... etc. Or is the speed in making the first prototype only?
I'm interested in answers from people who worked long time on Java and long time on other languages.
Note: I have ... | What makes other languages faster than Java in terms of Rapid Development? | 0 | 0 | 0 | 970 |
7,333,852 | 2011-09-07T12:24:00.000 | 0 | 0 | 0 | 0 | javascript,python,ajax,api,specifications | 7,333,988 | 2 | false | 0 | 0 | For small APIs I´ve began to use Google Docs. Its collaboration features are awesome and you can see a list of all changes made on this document. | 1 | 2 | 0 | Im creating the front end for a web service, and another company the back end. I need a good, simple and easily understandable way of making a document of API calls that we can collaborate on and edit together without confusing one another.
are there any good specs/examples etc of project API documentation so this does... | Good examples/templates/best practices API documentation | 0 | 0 | 1 | 1,413 |
7,334,498 | 2011-09-07T13:16:00.000 | 2 | 0 | 0 | 0 | python,django,django-sites | 7,335,351 | 3 | false | 1 | 0 | For this case, you would have 2 settings.py files called settings_A.py and settings_B.py which specify from settings import *
A would have SITE=1 and B would have SITE=B. you can then set these files in your apache configs by setting the environment variable for each virtual host DJANGO_SETTINGS_MODULE=settings_A and D... | 1 | 6 | 0 | I need split my current Django application into two sites.
Site A will contain the public facing site which would contain all the static pages and the registration system.
The other site — Site B — is the site for registered users. They can also log-in to application site through Site B.
If I'm not mistaken, I can us... | Separate Django sites with a common authetication/registration backend | 0.132549 | 0 | 0 | 227 |
7,334,587 | 2011-09-07T13:23:00.000 | 3 | 1 | 0 | 1 | php,python,process,centos,process-management | 7,334,651 | 1 | false | 0 | 0 | is there any way to keep these processes running in such a way that all the variables are saved and i can restart the script from where it stopped?
Yes. It's called creating a "checkpoint" or "memento".
i know i can program this
Good. Get started. Each problem is unique, so you have to create, save, and reload t... | 1 | 1 | 0 | I need to run a bunch of long running processes on a CENTOS server.
If I leave the processes (python/php scripts) to run sometimes the processes will stop running because of trivial errors eg. string encoding issues or sometimes because the process seems to get killed by the server.
I try to use nohup and fire the jobs... | running really long scripts - how to keep them running and start them again if they fail? | 0.53705 | 0 | 0 | 137 |
7,335,185 | 2011-09-07T14:02:00.000 | 4 | 1 | 0 | 0 | python,eclipse,debugging,aptana | 7,522,349 | 2 | true | 0 | 0 | This is because Aptana/Eclipse doesn't "realize" that the file you opened should be debugged using the Python debugger as it's not associated with a Python project/perspective (there's a lot of environment setup when a project is created in Aptana/Eclipse).
The simplest solution, IMO, would be to create a simple sandb... | 1 | 3 | 0 | In search of a Python debugger I stumbled upon Aptana, which is based on eclipse.
Often, I want to debug a single python script. However, Aptana won't let me run/debug the currently opened file directly.
Instead, it requires me to create a debug/run configuration for each file I would like to run/debug. Alternatively I... | eclipse: Run/Debug current file | 1.2 | 0 | 0 | 2,990 |
7,335,308 | 2011-09-07T14:10:00.000 | 8 | 0 | 0 | 0 | python,image,opencv | 7,337,353 | 6 | true | 0 | 0 | Unfortunately OpenCV does not support TIFF directories and is able to read only the first frame from multi-frame TIFF files. | 1 | 10 | 1 | Anyone know if OpenCV is capable of loading a multi-frame TIFF stack?
I'm using OpenCV 2.2.0 with python 2.6. | Can I load a multi-frame TIFF through OpenCV? | 1.2 | 0 | 0 | 12,017 |
7,335,829 | 2011-09-07T14:42:00.000 | 1 | 0 | 1 | 0 | python,django,string,json,boolean | 7,335,934 | 4 | false | 0 | 0 | The better way would be to avoid generating JSON by hand, or via Django templates, and instead use a proper JSON library. In Python 2.6+ this is as simple as import json. In older Pythons, you'll need to pip install simplejson and import simplejson as json.
It can be tough to generate proper JSON on your own—your exp... | 1 | 6 | 0 | Is there a best-practice for outputting Booleans in Python? I'm generating some JSON (via Django templates), and by default all the Boolean values are output with leading character in uppercase, contrary to the JSON standard (ie, "True" as opposed to "true").
Currently, I format each Boolean string using str.lower(), b... | python json boolean to lowercase string | 0.049958 | 0 | 0 | 19,079 |
7,335,957 | 2011-09-07T14:53:00.000 | 0 | 0 | 1 | 0 | python | 7,336,599 | 2 | false | 0 | 0 | You can make this by open cmd.exe and type here "C:\Python32\python".
Path is depend on the version of python. Mine is 3.2. | 1 | 0 | 0 | Is there a simple module that let's you paste input in python ?
Asking someone to type letter by letter is kinda harsh .
By default a .py file is opened with python.exe if is installed and this does not allow "rightclick+paste" in the console .So how can i make this happen with python ? i think this would be more of a... | Python raw_input() unable to paste in windows? | 0 | 0 | 0 | 1,567 |
7,336,096 | 2011-09-07T15:02:00.000 | 155 | 0 | 1 | 0 | python,glob | 20,384,686 | 9 | false | 0 | 0 | This might help someone:
names = [os.path.basename(x) for x in glob.glob('/your_path')] | 1 | 119 | 0 | Is there a way I can use glob on a directory, to get files with a specific extension, but only the filename itself, not the whole path? | Python Glob without the whole path - only the filename | 1 | 0 | 0 | 128,962 |
7,336,101 | 2011-09-07T15:03:00.000 | 8 | 1 | 0 | 0 | python,unit-testing,testing,rest,flask | 7,355,552 | 2 | true | 1 | 0 | There are 2 standard ways of approaching a test that depends on something else (object, function call, etc).
You can use mocks in place of the objects the code you are testing depends on.
You can load a fixture or do the creation/call in the test setup.
Some people like "classical" unit tests where only the "unit" of... | 1 | 11 | 0 | I want to know the best/different ways to test a REST API which uses a database backend. I've developed my API with Flask in Python and want to use unittest or nose.
But my problem, is that some resources require another resource to create them in the first place. Is there a way to say that to test the creation of a bl... | Testing REST API with database backend | 1.2 | 0 | 0 | 7,898 |
7,337,966 | 2011-09-07T17:23:00.000 | 1 | 0 | 0 | 0 | c++,python,proxy,network-programming | 7,338,903 | 2 | false | 0 | 0 | Why re-engineer the wheel? Why not just use OpenVPN, n2n or vtun etc etc. | 1 | 0 | 0 | I have an application which communicates over the local area network. However, I want to instead make it communicate over the internet. To do this I propose making an intermediate program which will read the network traffic generated from the application on one computer and send it to the application on another compute... | How to create a generic network proxy using Python or C++? | 0.099668 | 0 | 1 | 1,131 |
7,341,005 | 2011-09-07T21:57:00.000 | 10 | 0 | 1 | 0 | python,nose,peewee | 7,341,671 | 2 | true | 1 | 0 | Perhaps examining sys.argv[0] to see what command is running? | 1 | 8 | 0 | I'm running nosetests which have a setup function that needs to load a different database than the production database. The ORM I'm using is peewee which requires that the database for a model is set in the definition.
So I need to set a conditional variable but I don't know what condition to use in order to check if n... | Python: Conditional variables based on whether nosetest is running | 1.2 | 0 | 0 | 1,720 |
7,342,102 | 2011-09-08T01:04:00.000 | 0 | 0 | 1 | 0 | python,python-c-api | 7,355,902 | 2 | true | 0 | 0 | It appears the Py_INCREF simply doesn't actually increment the refcount. | 1 | 3 | 0 | I have a C++ library which uses Python callbacks. The callback, i.e. PyObject*, is stored in an object of class UnaryFunction, and the constructor Py_INCREFs it. The destuctor Py_XDECREFs it. That's the problem. The interpreter segfaults on that DECREF.
My solution is to just not DECREF it, but that seems wrong.
What i... | Why do Python functions get garbage collected? | 1.2 | 0 | 0 | 406 |
7,343,714 | 2011-09-08T06:00:00.000 | 3 | 0 | 0 | 0 | python,linux,gtk,glade | 7,347,414 | 1 | true | 0 | 1 | Libglade was a separate library. It since has been deprecated, and the functionnalities have been integrated in GTK, which uses the GTK builder format which is a bit different. Both formats allow almost the same things, but the GtkBuilder one is prefered. | 1 | 2 | 0 | I'm using glade interface designer for developing a simple application. I was actually following a tutorial which was based on libglade format. But I want to use the gtkbuilder format. So I switched to the gtkbuilder format. But I just want to know what is the exact difference between libglade format and gtkbuilder fo... | What is the difference between gtk builder file and libglade file when using Glade designer? | 1.2 | 0 | 0 | 852 |
7,344,835 | 2011-09-08T07:53:00.000 | 1 | 0 | 1 | 1 | python,plugins | 7,345,262 | 1 | true | 0 | 0 | I don't have access to the Envisage plugins documentation, so I'm not sure how these are installed. In general what you need to do is open Windows -> Preferences -> PyDev -> Interpreter - Python and check that the package directory is present in the System PYTHONPATH window. If it isn't add it and press Apply.
If your ... | 1 | 0 | 0 | I just installed the envisagecore and envisageplugin in Ubuntu 10.04. I'm using Eclipse SDK and PyDev plugin. How can I import this plugin in Eclipse? | Installing and including envisage plugin | 1.2 | 0 | 0 | 147 |
7,346,079 | 2011-09-08T09:44:00.000 | 0 | 0 | 0 | 0 | python,sqlite | 34,628,302 | 3 | false | 0 | 0 | To follow up on Thilo's answer, as a data point, I have a sqlite table with 2.3 million rows. Using select count(*) from table, it took over 3 seconds to count the rows. I also tried using SELECT rowid FROM table, (thinking that rowid is a default primary indexed key) but that was no faster. Then I made an index on one... | 3 | 2 | 0 | I have a single table in an Sqlite DB, with many rows. I need to get the number of rows (total count of items in the table).
I tried select count(*) from table, but that seems to access each row and is super slow.
I also tried select max(rowid) from table. That's fast, but not really safe -- ids can be re-used, table c... | Fast number of rows in Sqlite | 0 | 1 | 0 | 3,251 |
7,346,079 | 2011-09-08T09:44:00.000 | 1 | 0 | 0 | 0 | python,sqlite | 7,346,136 | 3 | false | 0 | 0 | Do you have any kind of index on a not-null column (for example a primary key)? If yes, the index can be scanned (which hopefully does not take that long). If not, a full table scan is the only way to count all rows. | 3 | 2 | 0 | I have a single table in an Sqlite DB, with many rows. I need to get the number of rows (total count of items in the table).
I tried select count(*) from table, but that seems to access each row and is super slow.
I also tried select max(rowid) from table. That's fast, but not really safe -- ids can be re-used, table c... | Fast number of rows in Sqlite | 0.066568 | 1 | 0 | 3,251 |
7,346,079 | 2011-09-08T09:44:00.000 | 1 | 0 | 0 | 0 | python,sqlite | 7,346,821 | 3 | false | 0 | 0 | Other way to get the rows number of a table is by using a trigger that stores the actual number of rows in other table (each insert operation will increment a counter).
In this way inserting a new record will be a little slower, but you can immediately get the number of rows. | 3 | 2 | 0 | I have a single table in an Sqlite DB, with many rows. I need to get the number of rows (total count of items in the table).
I tried select count(*) from table, but that seems to access each row and is super slow.
I also tried select max(rowid) from table. That's fast, but not really safe -- ids can be re-used, table c... | Fast number of rows in Sqlite | 0.066568 | 1 | 0 | 3,251 |
7,346,342 | 2011-09-08T10:09:00.000 | 5 | 0 | 0 | 0 | python,regex,django,referrer | 7,346,457 | 1 | true | 1 | 0 | in the meta dictionary of request there is a HTTP_REFERER value .. I think that can help you | 1 | 3 | 0 | I want to know who refers my webpage, so in my models I have:referrer = models.CharField(max_length=30, default='google',
verbose_name=_('referrer'), help_text=_('Referrer'))
This are the URL's for my page:url(r'^$', app_views.index, name='index_default') and url(r'^(\w+)/$', app_views.index, name='index_defaul... | Django referrer question | 1.2 | 0 | 0 | 2,659 |
7,347,233 | 2011-09-08T11:20:00.000 | 14 | 0 | 1 | 0 | python,jenkins,pylint | 7,347,681 | 9 | false | 0 | 0 | Pylint has the unpleasant behavior to return a non-zero exit code even only if a small warning issue was found. Only when everything was fine, 0 is returned (see man page).
As usually a non-zero code denotes an error, Jenkins fails the build.
I see two ways to overcome this:
Use a small script around pylint that alway... | 5 | 12 | 0 | I added a build step to execute a Python script.
In this script pylint is called with the lint.Run(..args) to check the code.
The script works but in the end, the build fails with the only error message:
Build step 'Execute Python script' marked build as failure
Someone has an idea why this happens? | Jenkins with pylint gives build failure | 1 | 0 | 0 | 15,177 |
7,347,233 | 2011-09-08T11:20:00.000 | 24 | 0 | 1 | 0 | python,jenkins,pylint | 9,049,403 | 9 | false | 0 | 0 | You can also simply put a
pylint || exit 0
in the shell cmdline. The Pylint plugin will fail the build anyway by checking the result of pyllint. | 5 | 12 | 0 | I added a build step to execute a Python script.
In this script pylint is called with the lint.Run(..args) to check the code.
The script works but in the end, the build fails with the only error message:
Build step 'Execute Python script' marked build as failure
Someone has an idea why this happens? | Jenkins with pylint gives build failure | 1 | 0 | 0 | 15,177 |
7,347,233 | 2011-09-08T11:20:00.000 | 3 | 0 | 1 | 0 | python,jenkins,pylint | 7,347,511 | 9 | true | 0 | 0 | it seems that your pylint execution exit with a non-zero status (missing script, bad options...), maybe you exit the script with an exception raised or a sys.exit(something_else_than_zero) | 5 | 12 | 0 | I added a build step to execute a Python script.
In this script pylint is called with the lint.Run(..args) to check the code.
The script works but in the end, the build fails with the only error message:
Build step 'Execute Python script' marked build as failure
Someone has an idea why this happens? | Jenkins with pylint gives build failure | 1.2 | 0 | 0 | 15,177 |
7,347,233 | 2011-09-08T11:20:00.000 | 0 | 0 | 1 | 0 | python,jenkins,pylint | 70,353,684 | 9 | false | 0 | 0 | The pylint give not zero exit, but without obviously error message. you may need to trace to see which file pylint got failed. and take a look in the file.
For me, I add an empty directory with init.py file, and pylint give same error | 5 | 12 | 0 | I added a build step to execute a Python script.
In this script pylint is called with the lint.Run(..args) to check the code.
The script works but in the end, the build fails with the only error message:
Build step 'Execute Python script' marked build as failure
Someone has an idea why this happens? | Jenkins with pylint gives build failure | 0 | 0 | 0 | 15,177 |
7,347,233 | 2011-09-08T11:20:00.000 | 1 | 0 | 1 | 0 | python,jenkins,pylint | 60,814,909 | 9 | false | 0 | 0 | Pylint expect the code being analyzed to be 100% perfect.
Even code warning may cause exit with non zero status code.
Try to fix your code as Pylint suggest and rate 10/10.
Hope this helps. | 5 | 12 | 0 | I added a build step to execute a Python script.
In this script pylint is called with the lint.Run(..args) to check the code.
The script works but in the end, the build fails with the only error message:
Build step 'Execute Python script' marked build as failure
Someone has an idea why this happens? | Jenkins with pylint gives build failure | 0.022219 | 0 | 0 | 15,177 |
7,350,851 | 2011-09-08T15:46:00.000 | 0 | 0 | 1 | 0 | python,csv,datestamp | 7,351,024 | 2 | false | 0 | 0 | The basic outline of the program is going to be like this:
Use the os module to get the filenames out of the directory/directories of interest
Read in each file one at a time
For each line in the file, split it into columns with columns = line.split(",")
Use datetime.date to convert strings like "2011-05-03" to dateti... | 1 | 2 | 1 | I have about 100 CSV files I have to operate on once a month and I was trying to wrap my head around this but I'm running into a wall. I'm starting to understand some things about Python, but combining several things is still giving me issues, so I can't figure this out.
Here's my problem:
I have many CSV files, and h... | Need to do a math operation on every line in several CSV files in Python | 0 | 0 | 0 | 2,947 |
7,351,270 | 2011-09-08T16:17:00.000 | 0 | 0 | 1 | 0 | python,list,printing,format | 64,779,246 | 3 | false | 0 | 0 | Lovely code, Edward, but doesn't work for me. Output:
{1: [8, 0.3333333333333333, [0.14285714285714285]]}
A breakpoint on the line after isinstance(float) triggers ONLY if I feed pprint a single float.
Python 3.9 on Windows 10, run under VS Code 1.50.1 | 1 | 10 | 0 | I have a list with floating point number named a. When I print the list with print a. I get the result as follows.
[8.364, 0.37, 0.09300000000000003, 7.084999999999999, 0.469, 0.303, 9.469999999999999, 0.28600000000000003, 0.2290000000
000001, 9.414, 0.9860000000000001, 0.534, 2.1530000000000005]
Can I tell the list pr... | Control a print format when printing a list in Python | 0 | 0 | 0 | 9,242 |
7,351,744 | 2011-09-08T16:56:00.000 | 122 | 0 | 1 | 0 | python,string | 7,351,789 | 3 | true | 0 | 0 | Use rpartition(s). It does exactly that.
You can also use rsplit(s, 1). | 1 | 103 | 0 | I would like to know if there is any built in function in python to break the string in to 2 parts, based on the last occurrence of a separator.
for eg:
consider the string "a b c,d,e,f" , after the split over separator ",", i want the output as
"a b c,d,e" and "f".
I know how to manipulate the string to get the desir... | split string in to 2 based on last occurrence of a separator | 1.2 | 0 | 0 | 62,919 |
7,352,021 | 2011-09-08T17:19:00.000 | 1 | 1 | 0 | 1 | python,pexpect | 7,353,518 | 1 | true | 0 | 0 | See the DISPLAY and SSH_ASKPASS section of man ssh-add. | 1 | 1 | 0 | I'm attempting to automate scp commands with pexpect on Ubuntu. However, I keep getting a password GUI prompt with title "OpenSSH". How can I disable this behavior and use command line prompts instead? | Python: how to launch scp with pexpect without OpenSSH GUI Password Prompt on Ubuntu? | 1.2 | 0 | 0 | 905 |
7,352,319 | 2011-09-08T17:45:00.000 | 1 | 1 | 0 | 0 | python,unit-testing,nose | 24,001,681 | 2 | false | 1 | 0 | nosetests --with-coverage -i project1/*.py -i project2/*.py | 1 | 11 | 0 | I have many projects that I'm programatically running:
nosetest --with-coverage --cover-html-dir=happy-sauce/
The problem is that for each project, the coverage module overwrites the index.html file, instead of appending to it. Is there a way to generate a combined super-index.html file, that contains the results for ... | Nosetests & Combined Coverage | 0.099668 | 0 | 0 | 3,218 |
7,354,834 | 2011-09-08T21:37:00.000 | 4 | 0 | 1 | 1 | python,file-io | 7,354,922 | 4 | false | 0 | 0 | What you're looking for is called privilege escalation, and it very much depends on the platform you're running on. In general, what your program would have to do is run a portion as the superuser. On unix systems, for instance, you might be able to use sudo to read the contents of the file.
But as mentioned, this rea... | 2 | 5 | 0 | I have to open a system file and read from it. This file is usually only readable by root (the super user). I have a way to ask the user for the superuser password. I would like to use this credentials to open the file and read from it without having my entire program running as a superuser process. Is there a way to a... | Open a file as superuser in python | 0.197375 | 0 | 0 | 11,540 |
7,354,834 | 2011-09-08T21:37:00.000 | 3 | 0 | 1 | 1 | python,file-io | 7,355,410 | 4 | false | 0 | 0 | I would split the program in two.
Handles opening the file and accessing the contents. It can assume it's started with the privileges it needs.
Everything else that doesn't require special privileges.
Put a config entry which describes how to exec or subprocess the command that requires extra privileges. ie.
acces... | 2 | 5 | 0 | I have to open a system file and read from it. This file is usually only readable by root (the super user). I have a way to ask the user for the superuser password. I would like to use this credentials to open the file and read from it without having my entire program running as a superuser process. Is there a way to a... | Open a file as superuser in python | 0.148885 | 0 | 0 | 11,540 |
7,357,007 | 2011-09-09T03:55:00.000 | 11 | 0 | 0 | 1 | python,macos,terminal | 53,871,077 | 2 | false | 0 | 0 | I had this same experience, and found python limits the length of input to raw_input if you do not import the readline module. Once I imported the readline module, it lifted the limit (or at least raised it significantly enough to where the text I was using worked just fine). | 2 | 7 | 0 | I wrote a python script and have been running it in terminal on Mac OS X snow leopard using python2.6. I used raw_input() to import text in several places, but I seem to reach a limit where it will no longer accept any more characters.
Is this a limit in python raw_input() or is this something to do with Terminal or Ma... | Python raw_input() limit with Mac OS X Terminal? | 1 | 0 | 0 | 2,834 |
7,357,007 | 2011-09-09T03:55:00.000 | 4 | 0 | 0 | 1 | python,macos,terminal | 7,357,025 | 2 | true | 0 | 0 | I'd say it's a limitation/bug with the OSX Terminal - try running the script with input via IDLE and see whether you still hit the same problem.
As for better ways of dealing with large input - it totally depends on your requirements but some ways could be:
Import text from a file
Create some kind of GUI/frontend to h... | 2 | 7 | 0 | I wrote a python script and have been running it in terminal on Mac OS X snow leopard using python2.6. I used raw_input() to import text in several places, but I seem to reach a limit where it will no longer accept any more characters.
Is this a limit in python raw_input() or is this something to do with Terminal or Ma... | Python raw_input() limit with Mac OS X Terminal? | 1.2 | 0 | 0 | 2,834 |
7,358,168 | 2011-09-09T06:58:00.000 | 0 | 0 | 1 | 0 | python,sockets,webserver,epoll | 7,358,217 | 2 | false | 0 | 0 | The epoll function (and the other functions in the same family poll and select) allow you to write single threading networking code that manage multiple networking connection. Since there is no threading, there is no need fot synchronisation as would be required in a multi-threaded program (this can be difficult to get... | 1 | 8 | 0 | I'm trying to write a scalable custom web server.
Here's what I have so far:
The main loop and request interpreter are in Cython. The main loop accepts connections and assigns the sockets to one of the processes in the pool (has to be processes, threads won't get any benefit from multi-core hardware because of the GIL)... | Should I use epoll or just blocking recv in threads? | 0 | 0 | 0 | 2,514 |
7,358,224 | 2011-09-09T07:05:00.000 | 0 | 0 | 0 | 0 | python | 7,358,989 | 2 | false | 0 | 0 | First I'd check if the browser has some kind of command line argument which could print such informations. I only checked Opera and it doesn't have one. What you could do is parse session file. I'd bet that every browser stores list of opened tabs/windows on disk (so it could recover after crash). Opera has this inform... | 1 | 1 | 0 | I would like to ask how can I get list of urls which are opened in my webbrowser, from example in firefox. I need it in Python.
Thanks | Get url from webbrowser in python | 0 | 0 | 1 | 1,872 |
7,361,447 | 2011-09-09T12:12:00.000 | 4 | 0 | 0 | 0 | python,algorithm,r,sparse-matrix,indices | 7,362,256 | 6 | true | 0 | 0 | Since you have two dense matrices then the double for loop is the only option you have. You don't need a sparse matrix class at all since you only want to know the list of indices (i,j) for which a[i,j] != b[i,j].
In languages like R and Python the double for loop will perform poorly. I'd probably write this in native ... | 1 | 6 | 1 | i have two sq matrix (a, b) of size in order of 100000 X 100000. I have to take difference of these two matrix (c = a-b). Resultant matrix 'c' is a sparse matrix. I want to find the indices of all non-zero elements. I have to do this operation many times (>100).
Simplest way is to use two for loops. But that's computat... | How to find indices of non zero elements in large sparse matrix? | 1.2 | 0 | 0 | 6,600 |
7,362,444 | 2011-09-09T13:35:00.000 | 0 | 0 | 1 | 0 | python,eclipse,debugging,pydev,remote-debugging | 7,378,199 | 2 | false | 0 | 0 | You need to add module to PYTHONPATH in Eclipse project settings and import it using the standard Python import. Then PyDev debugger should find it without any problems. | 1 | 0 | 0 | we´re having python source code stored in a sql database, the code is build together to a virtual python module and can be executed.
We want to debug this modules but then of course the Eclipse debugger host doesnt know where to find the source code for these modules.
Is there a way to provide pydevd with the location ... | Pydevd with virtual code or (source provider) | 0 | 0 | 0 | 211 |
7,362,952 | 2011-09-09T14:10:00.000 | -20 | 0 | 0 | 0 | python,django,unit-testing,django-queryset,django-testing | 7,363,032 | 9 | true | 1 | 0 | Not that I know of, but why not use an actual queryset? The test framework is all set up to allow you to create sample data within your test, and the database is re-created on every test, so there doesn't seem to be any reason not to use the real thing. | 1 | 38 | 0 | I have a utility function in my Django project, it takes a queryset, gets some data from it and returns a result. I'd like to write some tests for this function. Is there anyway to 'mock' a QuerySet? I'd like to create an object that doesn't touch the database, and i can provide it with a list of values to use (i.e. so... | Mocking a Django Queryset in order to test a function that takes a queryset | 1.2 | 0 | 0 | 24,744 |
7,363,997 | 2011-09-09T15:28:00.000 | 1 | 0 | 0 | 0 | python,graph | 7,364,602 | 1 | true | 0 | 0 | I'd start by parsing your indata to a map indexed by dates with counts as values. Just increase the count for each row with the same date you encounter.
After that, use some plotting module, for instance matplotlib to plot the keys of the map versus the values. That should cover it!
Do you need any more detailed ideas... | 1 | 1 | 1 | I am trying to graph alarm counts in Python to give some sort of display to give an idea of the peak amount of network elements down between two timespans. The way that our alarms report handles it is in CSV like this:
Name,Alarm Start,Alarm Clear
NE1,15:42 08/09/11,15:56 08/09/11
NE2,15:42 08/09/11,15:57 08/09/11
NE3,... | Graphing the number of elements down based on timestamps start/end | 1.2 | 0 | 0 | 52 |
7,365,035 | 2011-09-09T17:02:00.000 | 0 | 0 | 0 | 0 | python,django,character-encoding | 7,365,053 | 2 | false | 1 | 0 | Check the file encoding for your Python files. Make sure they're UTF-8. And also, make sure that the client side is also UTF-8. | 1 | 0 | 0 | I'm trying to send latin characters (é, è...) to the client side using Django, and I can't get it to work. In Django I tried to write directly latin characters in my python files, but I had errors. I then used unicode (writing 'Soci\u00E9t\u00E9' for 'Société'), but when sending it to the client side I get the raw unic... | Encoding issue between Django and client | 0 | 0 | 0 | 426 |
7,366,065 | 2011-09-09T18:42:00.000 | 0 | 0 | 0 | 0 | python,openldap | 7,396,220 | 1 | false | 0 | 0 | Usually it is just an update to the OU. For instance to set a custom password policy set the attribute pwdPolicySubentry with the value of a dn that points to the custom policy on the object. This would just be a straight forward modify operation. | 1 | 0 | 0 | i am trying to link gpos to OUs. Also, i want to add new gpos and modify policy settings/preferences. i am stuck at the latter part. any ideas/tips will be highly appreciated. | How to modify group policy object via python ldap? | 0 | 0 | 0 | 725 |
7,367,206 | 2011-09-09T20:41:00.000 | 0 | 0 | 1 | 0 | python,memory-management,stackless | 7,367,559 | 2 | false | 0 | 0 | Memory is separated at OS process level. There's no easy way to tell to which tasklet and even to which thread does a particular object belong.
Also, there's no easy way to add a custom bookkeeping allocator that would analyze which tasklet or thread is is allocating a piece of memory and prevent from allocating too mu... | 2 | 4 | 0 | We have a system that only has one interpreter. Many user scripts come through this interpreter. We want put a cap on each script's memory usage. There is only process, and that process invokes tasklets for each script. So since we only have one interpreter and one process, we don't know a way to put a cap on each scri... | How to track memory for a python script | 0 | 0 | 0 | 436 |
7,367,206 | 2011-09-09T20:41:00.000 | 3 | 0 | 1 | 0 | python,memory-management,stackless | 7,367,289 | 2 | true | 0 | 0 | I don't think that it's possible at all. Your questions implies that the memory used by your tasklets is completly separated, which is probably not the case. Python is optimizing small objects like integers. As far as I know, for example each 3 in your code is using the same object, which is not a problem, because it i... | 2 | 4 | 0 | We have a system that only has one interpreter. Many user scripts come through this interpreter. We want put a cap on each script's memory usage. There is only process, and that process invokes tasklets for each script. So since we only have one interpreter and one process, we don't know a way to put a cap on each scri... | How to track memory for a python script | 1.2 | 0 | 0 | 436 |
7,368,119 | 2011-09-09T22:29:00.000 | 0 | 0 | 1 | 0 | python,functional-programming | 7,391,685 | 3 | false | 0 | 0 | It's not a literal answer to your question, but I'd recommend to your friend to practice in Javascript instead of python. With python you can do some functional programming, but most projects don't need to do much if any. Javascript really requires doing this, and is at least as common/useful of a language these days... | 1 | 7 | 0 | I recommended to a friend to learn some functional programming using Python to expand his knowledge and overcome programmer's fatigue.
I chose Python because that way there's a good chance he'll be able to use the new knowledge in practical daily work.
I tried to find him some tutorials, and found a lot of guides - div... | What good homework style tutorials are recommended for learning functional programming in Python? | 0 | 0 | 0 | 539 |
7,368,288 | 2011-09-09T22:56:00.000 | 0 | 1 | 0 | 1 | python,aptana | 7,419,393 | 1 | false | 0 | 0 | Looks like that filepath is set up as an update site in your preferences. I'd just remove it, since it looks invalid (maybe you installed a pydev zip from here?). Go to Preferences > Install/Update > Available Software Sites and then remove the entry for it. | 1 | 0 | 0 | I am running Aptana Studio 3, build: 3.0.4.201108101506.
When I run "Check for updates" I get the following error
"A Problem occurred"
No repository found at file:/C:/Users/Keith/AppData/Local/Aptana%20Studio%203/plugins/com.python.pydev_2.2.1.2011073123/.
Any help would be appreciated | error when running "Check for updates" | 0 | 0 | 0 | 93 |
7,368,523 | 2011-09-09T23:34:00.000 | 1 | 0 | 0 | 1 | python,process,terminal,exit,terminate | 7,368,546 | 3 | false | 0 | 0 | Remember that system first spawns/forks a sub-shell to execute its commands. In effect, you are asking only the sub-shell to exit. | 2 | 2 | 0 | My friend is in a macOS environment and he wanted to call os.system('exit') at the end of his python script to make the terminal close. It doesn't. This doesn't surprise me but I would like to know what exactly is going on between the python script and the terminal when this call is made.
In my mental simulation the te... | os.system('exit') in python | 0.066568 | 0 | 0 | 10,910 |
7,368,523 | 2011-09-09T23:34:00.000 | 2 | 0 | 0 | 1 | python,process,terminal,exit,terminate | 7,368,553 | 3 | false | 0 | 0 | The system function starts another shell to execute a command. So in this case your Python scripts starts a shell and runs "exit" command in there, which makes that process exit. However, the Python script itself, including a terminal where it is running, continues to run. If the intent is to kill the terminal, you hav... | 2 | 2 | 0 | My friend is in a macOS environment and he wanted to call os.system('exit') at the end of his python script to make the terminal close. It doesn't. This doesn't surprise me but I would like to know what exactly is going on between the python script and the terminal when this call is made.
In my mental simulation the te... | os.system('exit') in python | 0.132549 | 0 | 0 | 10,910 |
7,369,271 | 2011-09-10T02:42:00.000 | 0 | 0 | 1 | 1 | python,macos,import | 7,372,654 | 2 | false | 0 | 0 | Workaround: Decided to simply add a .pth file to my site-packages directory which points to /usr/local/lib/python2.7/dist-packages
That is: Place in /Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages
a file shogun.pth which simply contains: /usr/local/lib/python2.7/dist-packages/ | 1 | 0 | 0 | I recently compiled the shogun library from source, but I'm not sure where I need to place the python files created. make install placed them in '/usr/local/lib/python2.7/dist-packages' which I assume is valid on linux systems.
sys.path in python doesn't have a dist-packages in its path, only a site-packages | Installing packages from source into EPD Python on Mac OS X | 0 | 0 | 0 | 791 |
7,370,757 | 2011-09-10T09:09:00.000 | 0 | 0 | 0 | 0 | python,django,bdd,lettuce | 7,370,790 | 1 | false | 1 | 0 | I do not know of lettuce, but I am guessing that you can include your file languages.py anywhere python can find it.
I do this by appending the directory containing my files into sys.path. You could overwrite PYTHONPATH instead. A directory containing python code should have a __init__.py file.
I am not sure if you a... | 1 | 0 | 0 | I've added lettuce into my django project, where to keep the languages.py file in django project instead of modifying lettuce itself?
Sultan | Django-lettuce: where to keep language file | 0 | 0 | 0 | 163 |
7,371,442 | 2011-09-10T11:39:00.000 | 1 | 1 | 0 | 0 | python,sockets,proxy | 7,378,232 | 1 | false | 0 | 0 | If it's a HTTP traffic, you can scan for headers like X-Forwarded-For.
But whatever you do it will always be only a heuristic. | 1 | 2 | 0 | Is there any way how to find out, if ip address comming to the server is proxy in Python?
I tried to scan most common ports, but i don't want to ban all ips with open 80 port, because it don't have to be proxy.
Is there any way how to do it in Python? I would prefere it before using some external/paid services. | Python - Determine if ip is proxy or not | 0.197375 | 0 | 1 | 328 |
7,371,878 | 2011-09-10T13:05:00.000 | 1 | 1 | 0 | 1 | python,linux,algorithm,archlinux | 7,372,533 | 2 | false | 0 | 0 | @shadyabhi: if you have many subdirectories maybe you can speedup the process by using os.listdir and multiprocessing.Process to recurse into each folder. | 2 | 3 | 0 | I am building a Music file organizer(in python2) in which I read the metadata of all files & then put those file in the required folder.
Now, I am already ready with the command line interface but this script shows feedback in a way that it shows "Which file is it working on right now?".
If the directory contains say 5... | Effective way to find total number of files in a directory | 0.099668 | 0 | 0 | 362 |
7,371,878 | 2011-09-10T13:05:00.000 | 2 | 1 | 0 | 1 | python,linux,algorithm,archlinux | 7,371,922 | 2 | true | 0 | 0 | I'm sorry to say this but no there isn't any way to do it more efficiently than recursively finding the files (at least that is platform (or filesystem) independent).
If the filesystem can help you it will, and you can't do anything to help it.
The reason it's not possible to do it without recursive scanning is how the... | 2 | 3 | 0 | I am building a Music file organizer(in python2) in which I read the metadata of all files & then put those file in the required folder.
Now, I am already ready with the command line interface but this script shows feedback in a way that it shows "Which file is it working on right now?".
If the directory contains say 5... | Effective way to find total number of files in a directory | 1.2 | 0 | 0 | 362 |
7,372,716 | 2011-09-10T15:30:00.000 | 5 | 0 | 1 | 0 | python,excel,parsing | 7,372,926 | 6 | false | 0 | 0 | xlrd is great for simple tasks, but if you need to work with any of Excel's deeper functionality (macros, advanced plotting, etc), and you are working on a windows machine, you can use the pywin32 library to control the win32com layer. This provides access to just about everything that can be controlled via macros / V... | 1 | 52 | 0 | I want to parse excel document to lists in Python.
Is there a python library which is helpful for this action?
And what functions are relevant in that library? | parsing excel documents with python | 0.16514 | 0 | 0 | 100,249 |
7,373,299 | 2011-09-10T17:18:00.000 | 1 | 1 | 0 | 0 | php,python,django,performance | 7,374,796 | 3 | false | 1 | 0 | You can think about PostgreSQL as Oracle, so from what I've found on the internet (because I am also a beginner) here is the order of DBs from smaller projects, to biggest:
SQLite
MySql
PostgreSQL
Oracle | 3 | 0 | 0 | I'm currently working on a social web application using python/django. Recently I heard about the PHP's weakness on large scale projects, and how hippo-php helped Facebook to overcome this barrier. Considering a python social web application with lot of utilization, could you please tell me if a similar custom tool cou... | Python/Django - Web Application Performance | 0.066568 | 0 | 0 | 1,518 |
7,373,299 | 2011-09-10T17:18:00.000 | 1 | 1 | 0 | 0 | php,python,django,performance | 7,376,098 | 3 | false | 1 | 0 | Don't try to scale too early! Of course you can try to be prepared but most times you can not really know where you need to scale and therefore spend a lot of time and money in wrong direction before you recognize it.
Start your webapp and see how it goes (agreeing with Spacedman here).
Though from my experience the la... | 3 | 0 | 0 | I'm currently working on a social web application using python/django. Recently I heard about the PHP's weakness on large scale projects, and how hippo-php helped Facebook to overcome this barrier. Considering a python social web application with lot of utilization, could you please tell me if a similar custom tool cou... | Python/Django - Web Application Performance | 0.066568 | 0 | 0 | 1,518 |
7,373,299 | 2011-09-10T17:18:00.000 | 3 | 1 | 0 | 0 | php,python,django,performance | 7,373,467 | 3 | true | 1 | 0 | The portion to rewrite in C++ is the portion that is too slow in Python. You need to figure out where your bottleneck is, which you can do by load testing or just waiting until users complain.
Of course, even rewriting in C++ might not help. Your bottleneck might be the database (move to a separate, faster DB server or... | 3 | 0 | 0 | I'm currently working on a social web application using python/django. Recently I heard about the PHP's weakness on large scale projects, and how hippo-php helped Facebook to overcome this barrier. Considering a python social web application with lot of utilization, could you please tell me if a similar custom tool cou... | Python/Django - Web Application Performance | 1.2 | 0 | 0 | 1,518 |
7,375,020 | 2011-09-10T22:10:00.000 | 1 | 0 | 0 | 0 | python,search,recursion,graph,depth-first-search | 7,375,081 | 2 | false | 0 | 0 | Recursion is about reducing a problem to a set of smaller problems.
In this case, let's say you are trying to find a route from node A to node Z. First you look at the neighbors of A. Let's say they are B, C, and D.
Now you have three sub-problems: finding a route from B to Z, C to Z, and D to Z. If you can solve any o... | 1 | 7 | 0 | I've been trying this all week and cannot, for the life of me, figure it out.
I know that I need to have a helper function that will recurse and return pathSoFar. I can't seem to get my head around the recursion.
I'm so confused that I can't even formulate exactly what the problem is besides recursion.
Thanks for any h... | depth-first graph search that returns path to goal | 0.099668 | 0 | 0 | 19,121 |
7,375,415 | 2011-09-10T23:49:00.000 | 1 | 0 | 0 | 0 | python,database,nosql,rdbms | 7,377,444 | 2 | true | 1 | 0 | I would recommend Postresql, only because it does what you want, can scale, is fast, rather easy to work with and stable.
It is exceptionally fast at the example queries given, and could be even faster with document querying. | 1 | 3 | 0 | I'm migrating a GAE/Java app to Python (non-GAE) due new pricing, so I'm getting a little server and I would like to find a database that fits the following requirements:
Low memory usage (or to be tuneable or predictible)
Fastest querying capability for simple document/tree-like data identified by key (I don't care a... | Low memory and fastest querying database for a Python project | 1.2 | 1 | 0 | 830 |
7,375,572 | 2011-09-11T00:33:00.000 | 2 | 0 | 0 | 0 | python,postgresql,psycopg2 | 7,378,101 | 2 | true | 0 | 0 | Can you paste in the data from the row that's causing the problem? At a guess I'd say it's a badly formatted date entry, but hard to say.
(Can't comment, so has to be in a answer...) | 2 | 0 | 0 | I am using Psycopg2 with PostgreSQL 8.4. While reading from a huge table, I suddenly get this cryptic error at the following line of code, after this same line of code has successfully fetched a few hundred thousand rows.
somerows = cursorToFetchData.fetchmany(30000)
psycopg2.DataError: invalid value "LÃ" for "DD"
DETA... | Cryptic Psycopg2 error message | 1.2 | 1 | 0 | 176 |
7,375,572 | 2011-09-11T00:33:00.000 | 1 | 0 | 0 | 0 | python,postgresql,psycopg2 | 40,247,155 | 2 | false | 0 | 0 | This is not a psycopg error, it is a postgres error.
After the error is raised, take a look at cur.query to see the query generated. Copy and paste it into psql and you'll see the same error. Then debug it from there. | 2 | 0 | 0 | I am using Psycopg2 with PostgreSQL 8.4. While reading from a huge table, I suddenly get this cryptic error at the following line of code, after this same line of code has successfully fetched a few hundred thousand rows.
somerows = cursorToFetchData.fetchmany(30000)
psycopg2.DataError: invalid value "LÃ" for "DD"
DETA... | Cryptic Psycopg2 error message | 0.099668 | 1 | 0 | 176 |
7,375,924 | 2011-09-11T02:20:00.000 | 0 | 1 | 0 | 1 | php,python,windows,apache,exec | 7,380,933 | 2 | false | 0 | 0 | Figured it out thanks to the excellent help from Winston Ewert and Gringo Suave.
I set Apache's service to the Local System Account and gave it access to interact with the desktop. This should help if you have Windows XP or Server 2003, but Vista and newer there's an Interactive Services Detection that pops up when yo... | 1 | 2 | 0 | First Note: Sorry this is long. Wanted to be thorough.
I really hate to ask a question when there's so much out there online but its been a week of searching and I have nothing to show for it. I'd really appreciate some help. I am a noob but I learn very fast and am more than willing to try alternate languages or whate... | PHP exec() command wont launch python script using sendkeys | 0 | 0 | 0 | 1,377 |
7,376,479 | 2011-09-11T05:30:00.000 | 0 | 0 | 0 | 0 | python,pygame | 31,993,464 | 2 | false | 0 | 1 | Just fill the screen with white and then draw the second screen onto the main screen. Then when you need the other screen, just refill the screen with black and then continue. It would help if both of your screens a function and you used a key like tab to "switch" between screens. | 2 | 2 | 0 | Is there any way way to create multiple screens in Pygame without redrawing to the screen every time. For example, if we want to create a splash screen, then a main menu with buttons. On clicking the 'Start Game' button, it would go to a new screen which is the actual game. What I mean is anything similar to the 'Form'... | Creating multiple screens in pygame | 0 | 0 | 0 | 6,820 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.