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,362,902
2010-12-06T03:20:00.000
1
0
1
0
python,django,django-templates
50,607,955
4
false
1
0
Django templates don’t just use Python code for the same reason Django uses the MVC paradigm:     No particular reason.     (ie: The same reason anyone utilizes MVC at all, and that reason is just that certain people prefer this rigid philosophical pattern.) In general I’d suggest you avoid Django if you don’t like thi...
3
9
0
I mean I understand that these templates are aimed at designers and other less code-savvy people, but for developers I feel the template language is just a hassle. I need to re-learn how to do very simple things like iterate through dictionaries or lists that I pass into the template, and it doesn't even seem to work v...
Why don't django templates just use python code?
0.049958
0
0
594
4,362,902
2010-12-06T03:20:00.000
1
0
1
0
python,django,django-templates
4,366,273
4
false
1
0
Seperation of concerns. Designer does design. Developer does development. Templates are written by the designers. Design and development are independent and different areas of work typically handled by different people. I guess having template code in python would work very well if one is a developer and their spouse i...
3
9
0
I mean I understand that these templates are aimed at designers and other less code-savvy people, but for developers I feel the template language is just a hassle. I need to re-learn how to do very simple things like iterate through dictionaries or lists that I pass into the template, and it doesn't even seem to work v...
Why don't django templates just use python code?
0.049958
0
0
594
4,364,507
2010-12-06T08:32:00.000
0
1
1
0
python,compiler-construction,programming-languages,interpreter
4,364,520
4
false
0
0
Generally, when someone says language X is written in X, they mean that first a compiler or interpreter for X was written in assembly or other such language, compiled, and then a better compiler or interpreter was written in X. Additionally, once a very basic compiler/interpreter for X exists, it is sometimes easier to...
2
1
0
A friend of mine that is a programmer told me that "Python is written in Python" or something like that. He meant that Python interpreter is written in Python (I think). I've read in some websites that Python interpret in real time ANY programming language (even C++ and ASM). Is this true? Could someone explain me HOW ...
Question about python construction
0
0
0
155
4,364,507
2010-12-06T08:32:00.000
5
1
1
0
python,compiler-construction,programming-languages,interpreter
4,364,861
4
false
0
0
It's not true. The standard implementation of Python - CPython - is written in C, although much of the standard library is written in Python. There are other implementations in Java (Jython) and .NET (IronPython). There is a project called PyPy which, among other things, is rewriting the C parts of Python into Python. ...
2
1
0
A friend of mine that is a programmer told me that "Python is written in Python" or something like that. He meant that Python interpreter is written in Python (I think). I've read in some websites that Python interpret in real time ANY programming language (even C++ and ASM). Is this true? Could someone explain me HOW ...
Question about python construction
0.244919
0
0
155
4,368,423
2010-12-06T16:11:00.000
1
0
1
0
python,inheritance,dictionary
4,368,488
7
false
0
0
An obvious alternative is to use a (v1,v2) tuple as the key into a single standard dict, and insert both (v1,v2) and (v2,v1) into the dictionary, making them refer to the same object on the right-hand side.
1
4
1
I have an algorithm in python which creates measures for pairs of values, where m(v1, v2) == m(v2, v1) (i.e. it is symmetric). I had the idea to write a dictionary of dictionaries where these values are stored in a memory-efficient way, so that they can easily be retrieved with keys in any order. I like to inherit from...
Symmetric dictionary where d[a][b] == d[b][a]
0.028564
0
0
1,589
4,368,885
2010-12-06T16:55:00.000
0
0
0
0
wxpython
4,370,204
1
false
0
1
Text controls eat mouse clicks so you may just want to catch the focus event for them. I think the rest should work though.
1
1
0
hey.. i have a panel (lets call it mainpanel) with a couple of panels in it and other widgets. i need to know what to bind the wx.EVT_LEFT_DOWN to in order for it to fire an event for clicks anywhere in mainpanel and its children. e.g. if i click on a textctrl in mainpanel i want it to pick that up aswell. binding to m...
wxpython, what to bind an application wide mouse event to
0
0
0
242
4,369,102
2010-12-06T17:19:00.000
1
0
0
1
python,wxpython
4,369,662
3
false
0
1
If you are running that in IDLE, then that is your problem. IDLE and wx don't get along very well because you basically end up with two mainloops fighting each other. Try putting it in a file and then run the file from the command line: c:\python27\python.exe myPyFile.py That should work just fine. Otherwise, download ...
3
1
0
Recently I installed wxPython to do some works under Windows. Most of the time I work in Linux so I have a little experience here. with python.exe interpreter, I just do 2 line of codeimport wxtmp=wx.App(False) Then the interpreter crashed with Windows error reporting. I tried both python 2.7.1 and 2.6.6 with wxPytho...
wx.App (wxPython) crash when calling
0.066568
0
0
1,983
4,369,102
2010-12-06T17:19:00.000
0
0
0
1
python,wxpython
4,496,450
3
true
0
1
I searched for a while and found that this is the problem with wxPython and Python >2.5. Tried many fix with manyfest file but no luck, so I think switch to PyQt is the only solution now.
3
1
0
Recently I installed wxPython to do some works under Windows. Most of the time I work in Linux so I have a little experience here. with python.exe interpreter, I just do 2 line of codeimport wxtmp=wx.App(False) Then the interpreter crashed with Windows error reporting. I tried both python 2.7.1 and 2.6.6 with wxPytho...
wx.App (wxPython) crash when calling
1.2
0
0
1,983
4,369,102
2010-12-06T17:19:00.000
1
0
0
1
python,wxpython
16,407,973
3
false
0
1
In case like me somebody will stumble into this question like I did. Recently installed wxpython on two machines, windows 7 and XP. Testing the sample code in simple.py (provided with the wxpython docs-demos installer), running from a python console, I had the following problem on both machines: First import ok, but wh...
3
1
0
Recently I installed wxPython to do some works under Windows. Most of the time I work in Linux so I have a little experience here. with python.exe interpreter, I just do 2 line of codeimport wxtmp=wx.App(False) Then the interpreter crashed with Windows error reporting. I tried both python 2.7.1 and 2.6.6 with wxPytho...
wx.App (wxPython) crash when calling
0.066568
0
0
1,983
4,369,261
2010-12-06T17:41:00.000
0
0
0
0
python,android,sl4a
4,531,739
1
false
0
1
Looks like the Control-K button actually toggles the left-ALT key on the PC to mimic the virtual keyboard left-ALT.
1
0
0
I'm using the Android 2.2 SDK emulator to test out the Scripting Layer for Android and have one annoyance. When you launch a Python interpreter and start to type code it appears that the parentheses key isn't mapped properly. When I hit the key on the PC keyboard I get ^[[20~ instead. What am I missing?
Android Emulator Keyboard
0
0
0
669
4,369,314
2010-12-06T17:47:00.000
9
0
0
0
python,web-applications
4,369,685
2
true
1
0
Step 1. Design a good game. Step 2. Be sure that it fits the HTTP model of simple request/reply GET/POST processing. Be sure that the game is still good. Some people try to do "real time" or "push" or other things that don't fit the model well and require lots of sophisticated GUI on the desktop. Step 3. Find a we...
1
3
0
I would like to design a web based game preferably in Python ( using Django maybe) though I'm open to any language other than Java/Flash/ActionScript. The idea I have in mind is more about data models than graphics and will leverage social networking sites. I would like to extend it with a mobile web interface in the f...
Designing a web based game that would run in a browser - Where should I start?
1.2
0
0
3,099
4,371,139
2010-12-06T21:29:00.000
1
1
0
0
python,silverlight,web-services,soap
4,371,795
2
false
0
0
I have used Spring WS, JAVA in my previous project. It worked well, without any glitches. We served more than a million API request a day.
1
3
0
I'm looking for a good framework to use for a soap service. I'd prefer to use a pythonic framework, but after looking at soaplib/rpclib (too unstable), SOAPy (doesn't work with 2.7) and ZSI (too...confusing), I'm not sure that's possible. I'm fine with it being in another language, though I'm hesitant to use php's soa...
What is a good framework for a soap service?
0.099668
0
1
1,264
4,371,947
2010-12-06T23:15:00.000
2
0
0
0
javascript,python,html,django,forms
4,372,018
1
true
1
0
If you validate the file separately you could store it before returning the error and provide an indication to the user that their upload has been saved (optionally allow them to choose between uploading yet another file or use the one from a previous submittal). This is a lot of extra housekeeping which could be stre...
1
3
0
Let's say someone submits a form. (I'm using Django's form framework completely) The form goes through my models.py and doesn't validate well. I redirect them back to the page, and display the form errors. All of the text boxes have their initial value in them, so the user doesn't have to retype them. But my "Choose F...
In Django, how can I keep the value of the File input after it is returned to it through an error?
1.2
0
0
517
4,372,870
2010-12-07T02:28:00.000
0
0
1
0
python,memcached,memcachedb
4,372,929
2
false
0
0
as I remember memcache has flag GET PRESERVE ORDER, try adding this to function flags
1
1
0
How can I preserve the order of the values fetched with memcache's get_multi() function? By default, the order returned is random. Thanks.
Python memcache preserve order in get_multi()
0
0
0
1,768
4,373,585
2010-12-07T05:07:00.000
2
0
1
1
python,multithreading,performance,profile
4,374,516
2
false
0
0
Depending on how far you've come in your troubleshooting, there are some tools that might point you in the right direction. "top" is a helpful start to show you if your problem is burning CPU time or simply waiting for stuff. "dtruss -c" can show you where you spend time and what system calls takes most of your time....
1
4
0
I have a program that is performing waaaay under par, and I would like to profile it. However, it is multithreaded, so I can't seem to find a good way to profile this thing. Any advice? I've tried yappi, but it segfaults on OS X :( EDIT: This is in python, sorry for putting it under profiling...
How can I profile a multithreaded program?
0.197375
0
0
1,368
4,376,500
2010-12-07T12:21:00.000
2
0
0
0
python,pygtk,gtk,filechooser
4,831,626
1
true
0
1
I was thinking about this, and although in your comments you've decided to go another route, I do have a suggestion: Write your own file chooser subclass of the GTK+ one and provide two "Open" buttons, one to "Open File" and another to "Open Directory". That would eliminate the ambiguity discussed above.
1
7
0
How do I get my filechooser to be able to select both files and folders when the open button on the filechooser dialog is hit ? I want to squeeze the ability to open files and filders in just one filechooser. I am using GTK+ and Python.
GTK+ Filechooser to open both files and folders
1.2
0
0
1,339
4,376,870
2010-12-07T13:04:00.000
5
0
0
0
python,tkinter
4,377,125
1
true
0
1
Tk is single-threaded, so if the main thread is busy the GUI will freeze. One solution is to use a separate thread to do the reading, so when the read blocks your main thread can continue. When you get a line of input you can push it on a queue which is monitored by the main thread. The other way is to figure out how ...
1
2
0
I am developing a Python 2.7.1 / Tkinter 8.4 app on Windows XP that checks several lines of input from a RS-232 port. However, if no input arrives it will sit in a loop for ever. I am trying to implement an ‘Abandon Test’ button on the GUI but because the main thread is busy waiting for input it doesn’t appear to eve...
How can I monitor Tkinter buttons when Python is busy?
1.2
0
0
987
4,378,653
2010-12-07T15:56:00.000
1
0
1
1
python,system,scheduler
4,378,686
2
false
0
0
Check the user context that System Scheduler is running under and ensure the location of Python is in it's PATH.
1
0
0
I have made a batch script which runs a Python application. This batch script is triggered by a program called System Scheduler, but when the program runs the batch script, it says that Python is not exisiting. When I run my batch script manually, I get no error. Can anyone explain this or come up with a solution?
Python is not existing when ran from System Scheduler
0.099668
0
0
78
4,378,924
2010-12-07T16:22:00.000
1
0
0
0
python,apache,webdav,outlook-2007,icalendar
4,443,166
1
true
0
0
Microsoft Outlook 2007 seems to have no ability to allow writing to an Internet Calendar. Icalendars are set to read only. You can publish a calendar to a webdav to create your own icalendar but that calendar (in your Outlook '07) would never update if someone else were to somehow edit that calendar (on the server). It...
1
1
0
I have been working on some custom shared Internet calendar software. I currently have a webdav server setup using apache and my software (using python) and right now it works great with Thunderbird and the Lightning plugin, I can subscribe to an icalendar and edit events with no problem. However I've run into a snag w...
Allow Outlook 2007 to edit custom shared iCalendars
1.2
0
1
1,189
4,379,160
2010-12-07T16:42:00.000
2
0
1
0
python,urllib2,connection,chunks
4,379,274
2
false
0
0
You need to write chunks it different temporary files and then join them in the original order. If you open one file for all the threads, you should make the access to it sequential to preserve to correct order of data, which discards thread usage since a thread should wait for the previous one. BTW, you should open fi...
2
0
0
so i am developing my own download manager for educational purpose. I have multiple connections/threads downloading a file, each connection works on a particular range of the file. Now after they have all fetched their chunks, i dont exact know how to i bring this chunks together to re-make the original file. What i ...
Download Manager: How to re-construct chunks fetched by multiple connections
0.197375
0
1
542
4,379,160
2010-12-07T16:42:00.000
1
0
1
0
python,urllib2,connection,chunks
4,379,227
2
true
0
0
You were doing it just fine: seek() and write(). That should work! Now, if you want a cleaner structure, without so many threads moving their hands all over a file, you might want to consider having downloader threads and a disk-writing thread. This last one may just sleep until woken by one of the others, write some k...
2
0
0
so i am developing my own download manager for educational purpose. I have multiple connections/threads downloading a file, each connection works on a particular range of the file. Now after they have all fetched their chunks, i dont exact know how to i bring this chunks together to re-make the original file. What i ...
Download Manager: How to re-construct chunks fetched by multiple connections
1.2
0
1
542
4,379,200
2010-12-07T16:46:00.000
0
0
0
1
python,google-app-engine,task-queue
4,379,300
2
false
1
0
This won't work directly as you describe it. Once a background task is started, it's a background task for its entire existence. If you want to return some information from the background task to the user, you'll have to add it to the datastore, and have a foreground handler check the datastore for that information. Y...
1
2
0
Currently I have tasks running in background. After the tasks are done executing I need to show output. How do I do this in Google App Engine? Once the tasks are done the only thing I can do is create another task which is supposed to show output or is there any other way?
how to bring a background task to foreground in google app engine?
0
0
0
282
4,379,330
2010-12-07T16:57:00.000
0
0
1
1
python,scripting,gnuplot
4,379,452
8
false
0
0
I create a file named test.txt containing plot [0:20] x; I run gnuplot test.txt and I see that gnuplot has indeed read contents of my file, so it does support arguments at runtime.
1
11
0
I have 500 files to plot and I want to do this automatically. I have the gnuplot script that does the plotting with the file name hard coded. I would like to have a loop that calls gnuplot every iteration with a different file name, but it does not seem that gnuplot support command line arguments. Is there an easy way...
Can Gnuplot take different arguments at run time? maybe with Python?
0
0
0
16,943
4,381,176
2010-12-07T20:20:00.000
0
0
1
0
python,multithreading,python-stackless
4,381,200
5
false
0
0
In CPython (the implementation of Python in C), no, according to my knowledge. (If I'm wrong, please correct me, I'd sure like to know if a solution exists!). You might want to be interested in IronPython (.NET) or JPython (Java/JWM). I haven't used them but I believe at least one of them supports threads native to the...
2
3
0
I wrote a beautiful multithreaded script, and when I ran it, it performed worse with 25 threads than with just direct invocation of the thread handler. Then I discovered the global interpreter lock. I want to ask, before I discard python for this script and rewrite the thing in something else, is there any way to do a...
Is there such a thing as working threading in python?
0
0
0
193
4,381,176
2010-12-07T20:20:00.000
1
0
1
0
python,multithreading,python-stackless
4,381,760
5
false
0
0
The correct answer depends heavily on what you're doing. Heavily CPU-bound (and blocking IO-bound) tasks, like compression and image rendering, are usually done with native code, and native libraries normally release the GIL while they work, which allows concurrency. When you can isolate the CPU-intensive work to a na...
2
3
0
I wrote a beautiful multithreaded script, and when I ran it, it performed worse with 25 threads than with just direct invocation of the thread handler. Then I discovered the global interpreter lock. I want to ask, before I discard python for this script and rewrite the thing in something else, is there any way to do a...
Is there such a thing as working threading in python?
0.039979
0
0
193
4,381,239
2010-12-07T20:28:00.000
2
1
1
0
python
4,381,283
2
false
0
0
The example I would give would be CCP Games who use Python for almost all code, iirc. They run eve online, a MMORPG with the record for the max amount of users online in one persistent universe (over 50 thousand yesterday afternoon for instance). So I would say that is a fairly large scale deployment, in my humble opin...
2
1
0
I am new to python and one thing I read is python is good for making fast prototype of your product because of its extensive library support. But it is not good(used) for large scale deployment? Is it true? your comments on this. I have not seen a place (domain) where it is heavily used although its a beautiful languag...
Python good for prototyping and not for large scale deployment?
0.197375
0
0
675
4,381,239
2010-12-07T20:28:00.000
2
1
1
0
python
4,381,275
2
true
0
0
Google uses it, and I think this is a good example for large-scale deployment. It is not very fast, indeed, but it has awesome C/C++ integration support for the bottlenecks.
2
1
0
I am new to python and one thing I read is python is good for making fast prototype of your product because of its extensive library support. But it is not good(used) for large scale deployment? Is it true? your comments on this. I have not seen a place (domain) where it is heavily used although its a beautiful languag...
Python good for prototyping and not for large scale deployment?
1.2
0
0
675
4,381,806
2010-12-07T21:32:00.000
1
1
1
0
.net,python
4,381,862
4
false
0
0
The only language I can think of that looks like Python today is Ruby, but Ruby was actually influenced by Python. It doesn't really look like anything you've ever used in .NET unless you used IronPython or IronRuby. Don't let that discourage you, Python is very simple to learn and most of the syntax (e.g. operators) w...
2
3
0
I want to start programming in python and I was wondering, which languages does Python resemble in syntax? I am familiar with .net.
Which of the languages does Python resemble in its class syntax?
0.049958
0
0
1,860
4,381,806
2010-12-07T21:32:00.000
4
1
1
0
.net,python
4,383,242
4
false
0
0
Python's abstract syntax is heavily inspired by C, as is its concrete micro-syntax. Its concrete macro-syntax, though is fairly different from C, since it uses indentation and dedentation to delimit blocks, similar to Haskell, F#, ISWIM and a couple of others. Semantically, Python is probably closer to something like M...
2
3
0
I want to start programming in python and I was wondering, which languages does Python resemble in syntax? I am familiar with .net.
Which of the languages does Python resemble in its class syntax?
0.197375
0
0
1,860
4,383,614
2010-12-08T02:15:00.000
0
0
0
0
python,gtk,drawing,pygtk
4,383,675
2
false
0
1
I found a solution that uses the queue_draw() method (callable from the Gtk.DrawingArea but seems like a method every gtk widget must have), but there are probably alternatives since this one implies it might get delayed, even though in my tests it didn't happen.
1
2
0
Currently I'm drawing some things in a subclass of DrawingArea, where I get a cairo context inside an expose-event and call a draw method from there. (according to some PyGTK tutorial I found) I'm used to doing a repaint() with java, but how can I get the same effect here?
(Py)GTK: How can I force my window to be repainted / call expose-event?
0
0
0
3,673
4,384,098
2010-12-08T04:12:00.000
2
0
0
0
python,database,django,string,integer
57,703,695
5
false
1
0
Null: It is database-related. Defines if a given database column will accept null values or not. Blank: It is validation-related. It will be used during forms validation, when calling form.is_valid(). Default: All Time it store the given value(default value) to the field if one doesn't provide any value for this field....
2
70
0
null=True blank=True default = 0 What's the difference? When do you use what?
In Django models.py, what's the difference between default, null, and blank?
0.07983
0
0
32,547
4,384,098
2010-12-08T04:12:00.000
2
0
0
0
python,database,django,string,integer
28,214,919
5
false
1
0
In implementation terms: The 'blank' field corresponds to all forms. Specifies if this value is required in form and corresponding form validation is done. 'True' allows empty values. The 'null' field corresponds to DB level. It will be set as NULL or NOT NULL at the DB. Hence if leave a field empty in admin with blank...
2
70
0
null=True blank=True default = 0 What's the difference? When do you use what?
In Django models.py, what's the difference between default, null, and blank?
0.07983
0
0
32,547
4,384,796
2010-12-08T06:33:00.000
11
1
1
0
python,github
4,384,952
5
false
0
0
A crude way I can think of is to make a symlink to README called README.rst and check them both in.
1
37
0
Python packaging tools expect that our readme file should be named README or README.txt. But if we follow this convention, GitHub displays it as plain text in the project page which is not pretty. (unlike the beautiful HTML version when named as README.rst) Is there any technique to make both PyPI and GitHub happy abou...
README extension for Python projects
1
0
0
11,100
4,385,839
2010-12-08T09:20:00.000
9
0
1
0
python,function,import
4,385,926
4
true
0
0
When you do a from foo import bar, you are importing the entire module. You are just making a copy of the symbol bar in the current namespace. You are not importing just the function. The reload function is not totally reliable (e.g. it will not work for compiled C modules). I would recommend that you exit and restart...
1
5
0
Using python in an interactive mode one imports a module then if the module is changed (a bug fix or something) one can simply use the reload() command. But what if I didn't import the entire module and used the 'from M import f,g' import statement. Is there any way to reimport only g? (I tried removing the function f...
reimporting a single function in python
1.2
0
0
3,806
4,387,138
2010-12-08T11:57:00.000
4
0
1
0
python,ascii
4,387,166
4
false
0
0
Use ord to convert a character into an integer, and chr for vice-versa.
1
24
0
Hi I need to be able to convert a ascii character into its decimal equivalent and vice-versa. How can I do that?
Python:Ascii character<->decimal representation conversion
0.197375
0
0
76,170
4,387,579
2010-12-08T12:48:00.000
6
0
1
0
python,c,api
4,387,614
2
false
0
0
Python itself does not save the result of the last operation. The Python REPL saves the last result in _, but you would not be using the REPL in this situation.
2
1
0
Where does Python save the result of the last operation? For example, If the last operation was math.sqrt(9), where does Python save the value 3.0? Or if the last operation was "hello " + "world!", where is the value 'hello world!' saved? I want to approach this from a C program (using Python's C API) and pass this va...
where python saves the result of the last operation?
1
0
0
2,190
4,387,579
2010-12-08T12:48:00.000
6
0
1
0
python,c,api
4,387,808
2
false
0
0
It doesn't. It sounds like you want to call Python code from C, and use the result in the rest of the C code. What you do is write a function in the Python code, and use its return value. It will be passed back as a PyObject* from the C API function that calls the Python function.
2
1
0
Where does Python save the result of the last operation? For example, If the last operation was math.sqrt(9), where does Python save the value 3.0? Or if the last operation was "hello " + "world!", where is the value 'hello world!' saved? I want to approach this from a C program (using Python's C API) and pass this va...
where python saves the result of the last operation?
1
0
0
2,190
4,390,129
2010-12-08T17:01:00.000
4
0
0
0
python,nltk,pypy
4,854,162
3
true
0
0
I got a response via email (Seo, please feel free to respond here) that said: The main issues are: PyPy implements Python 2.5. This means adding "from future import with_statement" here and there, rewriting usages of property.setter, and fixing up new in 2.6 library calls like os.walk. NLTK needs PyYAML. Simply symlink...
2
15
1
Does PyPy work with NLTK, and if so, is there an appreciable performance improvement, say for the bayesian classifier? While we're at it, do any of the other python environments (shedskin, etc) offer better nlkt performance than cpython?
Does PyPy work with NLTK?
1.2
0
0
2,318
4,390,129
2010-12-08T17:01:00.000
5
0
0
0
python,nltk,pypy
4,549,093
3
false
0
0
At least some of NLTK does work with PyPy and there is some performance gain, according to someone on #pypy on freenode. Have you run any tests? Just download PyPy from pypy.org/download.html and instead of "time python yourscript.py data.txt" type "time pypy yourscript.py data.txt".
2
15
1
Does PyPy work with NLTK, and if so, is there an appreciable performance improvement, say for the bayesian classifier? While we're at it, do any of the other python environments (shedskin, etc) offer better nlkt performance than cpython?
Does PyPy work with NLTK?
0.321513
0
0
2,318
4,391,487
2010-12-08T19:34:00.000
0
0
0
0
python,drupal,mod-wsgi
4,391,636
2
false
1
0
Drupal is a PHP-language framework, and wsgi/Django are waay too heavy for you IMHO. They're kinda designed to be used for the whole website. How about passthru in php? passthru — Execute an external program and display raw output You could execute the python script (maybe even with command line arguments from POST) ...
2
0
0
long time reader first time poster. I've recently been tasked with incorporating some python into a webpage for my employer. After doing some research it seemed that mod_wsgi and Django were the way to go, and it seemed to work great. However, my employer would like to maintain the site in Drupal and incorporate python...
passing information to mod_wsgi and returning to div tag
0
0
0
207
4,391,487
2010-12-08T19:34:00.000
0
0
0
0
python,drupal,mod-wsgi
4,391,744
2
false
1
0
1.) The only method I've found for passing information to a wsgi/python script is via POST and GET, is there an alternative or is this the standard method? This makes no sense out of context. If Apache (or whatever web server you're using) runs mod_wsgi, which runs Python, then the answer is "This is not only the stan...
2
0
0
long time reader first time poster. I've recently been tasked with incorporating some python into a webpage for my employer. After doing some research it seemed that mod_wsgi and Django were the way to go, and it seemed to work great. However, my employer would like to maintain the site in Drupal and incorporate python...
passing information to mod_wsgi and returning to div tag
0
0
0
207
4,392,902
2010-12-08T22:12:00.000
3
0
0
0
python,django,exception-handling,django-templates
4,395,425
2
true
1
0
Well, the trace is formatted by an internal template in views/debug.py. Look for TECHNICAL_500_TEMPLATE and for get_traceback_html() where it's used. So you could copy that template, hack it as you like, then monkeypatch it into django.view.debug. It ain't pretty, but this is fairly deep into the guts so you have to ex...
1
1
0
How can I change the template that django uses to display a stack trace when DEBUG mode is enabled and an exception gets caught at the top of the stack resulting in a 500? Apologies if this is a dupe question -- I'm sure the answer is stated simply somewhere, but owing to the nature of the search terms I'm having a har...
How to override the stack trace template in django?
1.2
0
0
331
4,393,310
2010-12-08T23:15:00.000
4
0
1
0
python,printing
4,394,520
4
false
0
0
if you call print from multiple threads, the output may be interleaved at the whim of the scheduler.
2
6
0
Is python's print synchronized? :) Between Threads.
Is python's print synchronized?
0.197375
0
0
3,348
4,393,310
2010-12-08T23:15:00.000
2
0
1
0
python,printing
28,769,999
4
false
0
0
The answer is no, threads can interrupt each other. However, you can use locks to avoid that. lock's prevent threads from interrupting each other on global things (specifically here the output screen) when a thread want's to use global thing with a lock, it first checks if the lock is unlocked, if not it waits until it...
2
6
0
Is python's print synchronized? :) Between Threads.
Is python's print synchronized?
0.099668
0
0
3,348
4,395,499
2010-12-09T06:29:00.000
13
1
1
0
python,static-analysis,pylint
19,118,976
5
false
0
0
To persistently disable warnings and conventions: Create a ~/.pylintrc file by running pylint --generate-rcfile > ~/.pylintrc Edit ~/.pylintrc Uncomment disable= and change that line to disable=W,C
2
28
0
Pylint looks like a good tool for running analysis of Python code. However, our main objective is to catch any potential bugs and not coding conventions. Enabling all Pylint checks seems to generate a lot of noise. What is the set of Pylint features you use and is effective?
Pylint best practices
1
0
0
32,053
4,395,499
2010-12-09T06:29:00.000
7
1
1
0
python,static-analysis,pylint
4,977,086
5
false
0
0
-E will only flag what Pylint thinks is an error (i.e., no warnings, no conventions, etc.)
2
28
0
Pylint looks like a good tool for running analysis of Python code. However, our main objective is to catch any potential bugs and not coding conventions. Enabling all Pylint checks seems to generate a lot of noise. What is the set of Pylint features you use and is effective?
Pylint best practices
1
0
0
32,053
4,396,727
2010-12-09T09:38:00.000
1
0
1
0
.net,visual-studio,dll,ironpython
4,414,812
1
true
0
1
There is no way to do this out of the box. You'd need to modify IronPython/DLR so that the calls from ClrModule.CompileToMethod down would pass an option to emit symbols and then ultimately call LambdaExpression.CompileToMethod to emit symbols.
1
1
0
I am running a .NET 3.5 C# project in Visual Studio 2008. In the project I am hosting an IronPython script that imports modules that I have compiled to .NET dlls with pyc. The version of IronPython is 2.6.1. I have used ObjectOperations.GetInstance and GetMember to wire up the python methods to the C# code. When I am d...
Is it possible to step into an IronPython dll compiled with pyc?
1.2
0
0
242
4,398,341
2010-12-09T12:46:00.000
0
1
0
0
php,python,ruby-on-rails,scalability,cassandra
9,921,879
1
false
1
0
Because Cassandra is written in Java, a client also in Java would likely have the best stability and maturity for your application. As far as choosing between those 3 dynamic languages, I'd say whatever you're most comfortable with is best. I don't know of any significant differences between client libraries in those ...
1
0
0
Which one of Ruby-PHP-Python is best suited for Cassandra/Hadoop on 500M+ users? I know language itself is not a big concern but I like to know base on proven success, infrastructure and available utilities around those frameworks! thanks so much.
Scability of Ruby-PHP-Python on Cassandra/Hadoop on 500M+ users
0
1
0
339
4,398,432
2010-12-09T12:56:00.000
0
1
1
0
java,python,reflection
54,568,702
6
false
1
0
The easiest way to handle this is to create a Map object in Java class & keep adding the name value pairs & retrieve it accordingly though it might not support different types that setAttr supports.
2
12
0
I'm converting some python code to java, and have a situation where I need to call methods of an object but don't know which methods until runtime. In python I resolve this by using getattr on my object and passing it a string that is the name of my method. How would you do something similar in Java?
Java equivalent of python's getattr?
0
0
0
4,915
4,398,432
2010-12-09T12:56:00.000
0
1
1
0
java,python,reflection
4,398,473
6
false
1
0
In Java you do this with the Reflection API (and it's usually pretty cumbersome). MethodUtils in Apache Commons BeanUtils project may make it a bit easier to work with, though it's a pretty hefty dependency for something simple like this.
2
12
0
I'm converting some python code to java, and have a situation where I need to call methods of an object but don't know which methods until runtime. In python I resolve this by using getattr on my object and passing it a string that is the name of my method. How would you do something similar in Java?
Java equivalent of python's getattr?
0
0
0
4,915
4,398,856
2010-12-09T13:45:00.000
0
0
1
0
asp.net,.net,wcf,python-idle
8,192,452
2
false
1
0
WCF is meant to be consumed and to fire events, not to host long-running processes. You really want WF (workflow foundation) or BizTalk to host some long-running events. WCF events are typically short lived. You can create a XAMLX which combines the two concepts.
1
0
0
I create a WCF Service Application that runs in IIS 7.0 . In its initialization I start an endless loop ( while(true) ) , but after a period of time ,where I didn't call a method from his svc file, the wcf pass in an idle mode, and it doesn't react in the process the loop has to do. It is like it stops working. And the...
WCF Service Applcation remaining idle until hit manually .svc file
0
0
0
314
4,398,962
2010-12-09T13:57:00.000
1
0
0
0
python,docutils
4,399,316
1
false
1
0
There is a meta directive to set meta tags if that's what you want. If you are wanting to control the whole web page with your own css and javascript then you might want to look at Sphinx and write your own theme.
1
2
0
This document (http://docutils.sourceforge.net/docs/ref/rst/directives.html) explains about using .. raw:: to pass through HTML code in docutils, and the HTML code is in the body part of generated HTML. How can I put something in heading part (..) with docutils?
How can I add something to the heading part of HTML document with docutils
0.197375
0
0
133
4,399,237
2010-12-09T14:23:00.000
4
0
0
0
python,tkinter,ttk
4,399,322
2
true
0
1
No, there is no equivalent. There is only pack_forget which doesn't remember where the widget was when you restore it. If I need this sort of feature I just use the grid geometry manager.
1
3
0
Is there a pack equivalent of the grid_remove() method where a widget's original pack() settings are restored on a re-pack()? Use case: When I show a packed widget that has been hidden via pack_forget(), I would like to have the widget re-packed with its original pack settings when I issue the widget.pack() show reques...
Python/Tkinter: pack equivalent of grid_remove(), eg. pack_remove()?
1.2
0
0
2,749
4,401,202
2010-12-09T17:23:00.000
18
0
0
0
python,user-interface,layout,tkinter,ttk
4,402,589
3
true
0
1
Neither is intrinsically better than the other. Each have strengths and weaknesses. Learn what those are and the choice of which to use becomes obvious. grid is considerably easier to use if you need to lay things out in a grid. pack is generally easier to use if all you need to do is put some widgets in a single row o...
3
31
0
Are there any best practice tips regarding when one should use pack vs. grid for their layouts? From what I've been reading via google, the concencus seems to be that grid can handle any pack scenario but not vice-versa. To start the conversation, it appears that one use case that favors grid vs. pack is when one wants...
When to use pack or grid layouts in tkinter?
1.2
0
0
33,054
4,401,202
2010-12-09T17:23:00.000
10
0
0
0
python,user-interface,layout,tkinter,ttk
4,411,675
3
false
0
1
I always recommend grid over pack for polished applications. There are only a few edge cases where pack is easier and fits the bill (everything in one row or col). grid has better "composability" (e.g. megawidgets or gridding elements of gridded elements). The reasons to prefer grid are the extra fine-tuning options...
3
31
0
Are there any best practice tips regarding when one should use pack vs. grid for their layouts? From what I've been reading via google, the concencus seems to be that grid can handle any pack scenario but not vice-versa. To start the conversation, it appears that one use case that favors grid vs. pack is when one wants...
When to use pack or grid layouts in tkinter?
1
0
0
33,054
4,401,202
2010-12-09T17:23:00.000
2
0
0
0
python,user-interface,layout,tkinter,ttk
4,401,215
3
false
0
1
I personally just think grid is a lot easier to work with, so I would use that. Of course, you've probably read the one thing you should never do is try to use both at the same time in the same container. Thank you Bryan Oakley for making that distinction.
3
31
0
Are there any best practice tips regarding when one should use pack vs. grid for their layouts? From what I've been reading via google, the concencus seems to be that grid can handle any pack scenario but not vice-versa. To start the conversation, it appears that one use case that favors grid vs. pack is when one wants...
When to use pack or grid layouts in tkinter?
0.132549
0
0
33,054
4,402,536
2010-12-09T19:58:00.000
4
0
1
0
python,debugging,vim
4,402,775
5
false
0
0
In case of my own projects, the source code is always in version control. Before committing, I always check the graphical diff so that I can see what has changed, what the commit message should be and whether I can split up into smaller commits. That way, I almost always recognize temporary garbage like print statement...
3
4
0
Sometimes when developing using open source software, you need to read it's source code (specially zope/plone). A lot of times I need to write print statements, or debug calls (import pdb), or comment try/except clauses, you name it. Sometimes I have a lot of files opened when trying to find an issue, and sometimes I f...
How do you avoid leaving debugger print/pdb statements in python open source apps when you're debugging them and just finish?
0.158649
0
0
991
4,402,536
2010-12-09T19:58:00.000
2
0
1
0
python,debugging,vim
4,402,792
5
false
0
0
Well +1 for starting this discussion. Yes sometime this happen to me. I left those pdb and commit the code to the central code base, git. I use 'emacs'. So, Before commit the code I usually search for pdb in the file. But it is hectic checking each file.So, Before committing the code I usually check the diff very caref...
3
4
0
Sometimes when developing using open source software, you need to read it's source code (specially zope/plone). A lot of times I need to write print statements, or debug calls (import pdb), or comment try/except clauses, you name it. Sometimes I have a lot of files opened when trying to find an issue, and sometimes I f...
How do you avoid leaving debugger print/pdb statements in python open source apps when you're debugging them and just finish?
0.07983
0
0
991
4,402,536
2010-12-09T19:58:00.000
1
0
1
0
python,debugging,vim
4,402,892
5
false
0
0
I also develop Python with Vim. I have never had to substantially modify the source code for debugging. I do sometimes put debugging print statements, and I have the habit of putting "# XXX" after every one. Then when I want to remove them (before a commit), and just search for the XXX and delete those lines. For exce...
3
4
0
Sometimes when developing using open source software, you need to read it's source code (specially zope/plone). A lot of times I need to write print statements, or debug calls (import pdb), or comment try/except clauses, you name it. Sometimes I have a lot of files opened when trying to find an issue, and sometimes I f...
How do you avoid leaving debugger print/pdb statements in python open source apps when you're debugging them and just finish?
0.039979
0
0
991
4,403,119
2010-12-09T21:06:00.000
3
0
1
0
python,pywin32
8,695,624
3
true
0
0
Is there a way to get pywin32 to use vcvars32.bat instead of vcvarsall.bat? There's no need. I realized that, since I have Visual Studio 2010 installed rather than 2008 or earlier, I have a file called "vcvars32.bat" instead of the usual "vcvarsall.bat". You have both and vcvars32.bat is being used by vcvarsal...
1
2
0
So, I'm just trying to build pywin32 on my Windows 7 machine. When running the setup script, I ran into the common error of "Unable to find vcvarsall.bat". I do have Visual C++ installed, so I was somewhat confused. After a bit of searching around, here as well as other sites, I found that the best solution to my probl...
Is there a way to get pywin32 to use vcvars32.bat instead of vcvarsall.bat?
1.2
0
0
1,930
4,403,150
2010-12-09T21:10:00.000
3
0
0
0
java,python,scala,opengl,jogl
4,435,696
2
true
0
1
I have used JOGL in many of my 3D projects. Learning how to use a binding is not as important as learning the actual api. Using opengl in c and java are pretty much the same. The only thing that differs is the way you set up your rendering windows and buffers. I use netbeans ide with the opengl for netbeans plugin beca...
1
3
0
one topic that has always been of highest interest to me is 3D Programming. I've made several attempts at programming small games and never really successed. After experiences with DirectX and C++, XNA and C#, as well as Unity3d and C#, I would like to try OpenGL. Just being curious. When using C++ the way to go is rat...
Key to OpenGL. Java / Scala / Python
1.2
0
0
1,677
4,404,126
2010-12-09T23:17:00.000
1
0
1
0
python
4,404,395
2
false
0
0
You need to weigh up the pros and cons of doing the port 2.5/6/7 gives you better programming structures, more libraries, etc. but you won't know how much work is involved with the port until you try it. I would imagine it's worthwhile spending say a day or two on the port If you feel you are getting nowhere after that...
1
0
0
Or, should we have a virutal environment and continue to run this on 2.3?
I already have a library that is in Python 2.3. Is there any advantage to rewriting it to 2.6?
0.099668
0
0
91
4,404,258
2010-12-09T23:38:00.000
6
0
0
1
python,installation,distutils
4,404,450
3
true
0
0
(Already worked, reposting as a proper answer): Try removing the "MANIFEST" file and re-running it. If you've moved files around, MANIFEST can be wrong (it gets regenerated automatically if it's not there).
2
5
0
I have a very simple setup: from distutils.core import setup setup(name='myscripts', description='my scripts', author='Ago', author_email='blah', version='0.1', packages=['myscripts'] ) myscripts folder consists of about 10 python files. Everthing works fine if I just execute my m...
distutils "not a regular file --skipped"
1.2
0
0
3,673
4,404,258
2010-12-09T23:38:00.000
0
0
0
1
python,installation,distutils
36,453,425
3
false
0
0
In my case this error was caused by inadvertly running distutils with Python 2.7 instead of Python 3. The quick fix: python3 setup.py register sdist upload Better still, mark the script correctly: sed -i '1i #!/usr/bin/python3' setup.py
2
5
0
I have a very simple setup: from distutils.core import setup setup(name='myscripts', description='my scripts', author='Ago', author_email='blah', version='0.1', packages=['myscripts'] ) myscripts folder consists of about 10 python files. Everthing works fine if I just execute my m...
distutils "not a regular file --skipped"
0
0
0
3,673
4,404,492
2010-12-10T00:13:00.000
4
0
1
0
python,regex
4,404,500
3
false
0
0
.* will always match as many characters as possible. Try (.*?) - most implementations should try to match as few characters as possible then (should work without the brackets but not sure right now). So your whole pattern should look like this: \/\*.*?\*\/ or \/\*(.*?)\*\/
3
2
0
So I have one variable that has all the code from some file. I need to remove all comments from this file. One of my regexp lines is this x=re.sub('\/\*.*\*\/','',x,re.M,re.S); What I want this to be doing is to remove all multi line comments. For some odd reason though, its skipping two instances of */, and removing e...
Small problem with reg exps in python
0.26052
0
0
80
4,404,492
2010-12-10T00:13:00.000
1
0
1
0
python,regex
4,404,514
3
false
0
0
The expression .* is greedy, meaning that it will attempt to match as many characters as possible. Instead, use (.*?) which will stop matching characters as soon as possible.
3
2
0
So I have one variable that has all the code from some file. I need to remove all comments from this file. One of my regexp lines is this x=re.sub('\/\*.*\*\/','',x,re.M,re.S); What I want this to be doing is to remove all multi line comments. For some odd reason though, its skipping two instances of */, and removing e...
Small problem with reg exps in python
0.066568
0
0
80
4,404,492
2010-12-10T00:13:00.000
1
0
1
0
python,regex
4,404,564
3
false
0
0
The regular expression is "greedy" and when presented with several stopping points will take the farthest one. Regex has some patterns to help control this, in particular the (?&gt!...) which matches the following expression only if it is Not preceeded by a match of the pattern in parens. (put in a pointy brace for...
3
2
0
So I have one variable that has all the code from some file. I need to remove all comments from this file. One of my regexp lines is this x=re.sub('\/\*.*\*\/','',x,re.M,re.S); What I want this to be doing is to remove all multi line comments. For some odd reason though, its skipping two instances of */, and removing e...
Small problem with reg exps in python
0.066568
0
0
80
4,404,825
2010-12-10T01:22:00.000
3
0
0
0
python,user-interface,gtk,pygtk
4,450,091
3
false
0
1
The calendar is a bit large, but you can find code putting it in a popup. Personally I use a regular text entry and parse the date. As for SpinButton, it is based on a text entry, so you might be able to modify its display only by fiddling with inherited signals and returning False. See also the update-policy and numer...
1
1
0
I want to make a gtk SpinButton, but for inputting dates. Is there an easier way to input dates into GTK? If not, how can I create a SpinButton look-alike, but whose output is text representing dates instead of integers? Ideally I'd re-use the arrows, the clicks, the integration with the adjustment, etc. I really just...
gtk custom spin button
0.197375
0
0
847
4,405,667
2010-12-10T04:29:00.000
10
1
0
0
python,twisted,gevent,eventlet
4,411,300
1
true
0
0
It's an issue of aesthetic preference, I think. First of all, eventlet can actually use Twisted for networking, so in a sense, it's not an either-or question, it's a this-is-built-on-top-of-that question. Personally, I don't see the need for libraries like gevent or eventlet, especially since the advent of the @inlineC...
1
9
0
Under what circumstances would something like eventlet/gevent be better than twisted? Twisted seems like the most used, but eventlet/gevent must have some advantages... I'm not looking for an answer to a specific scenario, just generalities.
Twisted, gevent eventlet - When would I use them
1.2
0
0
2,369
4,406,078
2010-12-10T05:48:00.000
1
0
1
0
python,windows-7,py2exe
4,422,119
2
true
0
0
When you package an app with py2exe, the result is usually a single executable (perhaps with some data files). This is simplest to update by just proposing the user to download and install a new version every once in a while (how you check with a server that such new version exists is a different question). If you want...
1
3
0
I have a Windows program that I made with python and py2exe. I'd like to create an updating feature so that the software can be readily updated. What are common ways of going about this?
What are common strategies for updating python programs?
1.2
0
0
225
4,406,448
2010-12-10T06:57:00.000
0
1
0
0
python,twitter,oauth
4,406,528
3
false
0
0
No one knows that. There were discussions on that in relation of how many users twitter really has. There were a lot of tests as well as probing of id ranges etc. The results were that the ids were sequentially incrementing a long time, but then had regular gaps of about 10 between them, and sometimes also seemed to be...
1
2
0
Would anyone happen to know what the maximum user ID is on Twitter? That is by now there are about 200mil users, so would the id's range from 1 - 200million? I am finding that in that range some of the id's are not used. I have a python script that is basically accessing the following url: "/1/statuses/user_timeline/" ...
Max Twitter ID?
0
0
1
3,366
4,406,501
2010-12-10T07:09:00.000
37
0
1
0
python,dictionary,sequence
20,563,278
22
false
0
0
In python 2.7 and higher, you can use dictionary comprehension: This is an example I encountered while reading a CSV using a DictReader. The user had suffixed all the column names with ':' ori_dict = {'key1:' : 1, 'key2:' : 2, 'key3:' : 3} to get rid of the trailing ':' in the keys: corrected_dict = { k.replace(':', ''...
2
526
0
I want to change the key of an entry in a Python dictionary. Is there a straightforward way to do this?
Change the name of a key in dictionary
1
0
0
540,196
4,406,501
2010-12-10T07:09:00.000
12
0
1
0
python,dictionary,sequence
4,411,748
22
false
0
0
Since keys are what dictionaries use to lookup values, you can't really change them. The closest thing you can do is to save the value associated with the old key, delete it, then add a new entry with the replacement key and the saved value. Several of the other answers illustrate different ways this can be accomplishe...
2
526
0
I want to change the key of an entry in a Python dictionary. Is there a straightforward way to do this?
Change the name of a key in dictionary
1
0
0
540,196
4,406,676
2010-12-10T07:42:00.000
1
0
0
0
python,web-applications,cgi,web-frameworks
4,406,739
2
false
1
0
A web framework is a toolkit designed to make working with HTTP requests within a certain language easier. It usually provides things like URL routing and HTML templating, and may optionally provide a ORM. It may or may not come with its own web server. On Python they are usually written to WSGI, of which there are ple...
1
4
0
I've asked this question on some places but I never get a completely straight answer. I've heard a lot about web frameworks and only know a basic understanding. Okay is a web framework installed on top of server architecture like apache or is it its own thing? I've read a good amount about web frameworks and I like wha...
what are python web frameworks
0.099668
0
0
335
4,407,843
2010-12-10T10:25:00.000
2
1
0
1
python,bash,shell
4,408,136
6
false
0
0
If the password is only accepted on the command line, you're pretty much out of luck. Are you absolutely sure there's no option to send the password in another way? If you can send it over the process's stdin, you can talk to it via a pipe, and send the password securely in that way.
3
12
0
i'm writing a python application that uses a command line utility (propietary so it can't be modified) to do part of its work. The problem is that I have to pass the password as a command line argument to the tool which would easily be seen by any user doing 'ps ax'. How can I send the password to the command line tool...
sending password to command line tools
0.066568
0
0
4,756
4,407,843
2010-12-10T10:25:00.000
0
1
0
1
python,bash,shell
13,034,720
6
false
0
0
You may be able to gain more security by having an encrypted password argument and passing an encrypted password, and the program can de-crypt it. At least there would be no plain-text password floating around. I used this method when launching a process via another process and passing it arguments. It may not be feasi...
3
12
0
i'm writing a python application that uses a command line utility (propietary so it can't be modified) to do part of its work. The problem is that I have to pass the password as a command line argument to the tool which would easily be seen by any user doing 'ps ax'. How can I send the password to the command line tool...
sending password to command line tools
0
0
0
4,756
4,407,843
2010-12-10T10:25:00.000
0
1
0
1
python,bash,shell
13,034,839
6
false
0
0
Write another python script that will accept password from command prompt using getpass.getpass() and store it in a variable. Then call the command from the script with that variable having password as parameter.
3
12
0
i'm writing a python application that uses a command line utility (propietary so it can't be modified) to do part of its work. The problem is that I have to pass the password as a command line argument to the tool which would easily be seen by any user doing 'ps ax'. How can I send the password to the command line tool...
sending password to command line tools
0
0
0
4,756
4,407,873
2010-12-10T10:29:00.000
73
0
1
0
python,data-structures,collections
4,407,915
5
true
0
0
() - tuple A tuple is a sequence of items that can't be changed (immutable). [] - list A list is a sequence of items that can be changed (mutable). {} - dictionary or set A dictionary is a list of key-value pairs, with unique keys (mutable). From Python 2.7/3.1, {} can also represent a set of unique values (mutable).
3
30
0
What's the difference between () vs [] vs {} in Python? They're collections? How can I tell when to use which?
What's the difference between () vs [] vs {}?
1.2
0
0
50,953
4,407,873
2010-12-10T10:29:00.000
3
0
1
0
python,data-structures,collections
4,407,967
5
false
0
0
In addition to the tuple, list and dict given by the other answers, {} also denotes a set literal in python 2.7 and python 3.1. (This makes sense because set elements act like the keys of a dict).
3
30
0
What's the difference between () vs [] vs {} in Python? They're collections? How can I tell when to use which?
What's the difference between () vs [] vs {}?
0.119427
0
0
50,953
4,407,873
2010-12-10T10:29:00.000
0
0
1
0
python,data-structures,collections
72,106,473
5
false
0
0
To complete the other answers about {}: If you see a = {"key1": 1, "key2": 2, "key3": 3} (keys and values), then it's a dict. If you see a = {1, 2, 3} (values only), then it's a set. If you see a = {} (empty), then it's a dict. An empty set is created with a = set(). Quoting the official doc: 5.4. Sets Python also inc...
3
30
0
What's the difference between () vs [] vs {} in Python? They're collections? How can I tell when to use which?
What's the difference between () vs [] vs {}?
0
0
0
50,953
4,409,789
2010-12-10T14:31:00.000
1
0
0
0
python,html,favicon,web-crawler
4,409,872
1
true
0
0
That's a feature of the ico file format. They're perfectly valid files, but you're going to need to process them with something that actually understands Windows Icon files.
1
0
0
I am using a script to crawl and download favicons from websites. Some sites gave me 2-3 favicon images of various sizes (16x16, 32x32) etc..embedded in the same image. When I try to use this image it is not displaying properly as a favicon. Is there anything that I can do to make sure I download a proper image?
Having issues while downloading favicon using python script
1.2
0
1
269
4,411,044
2010-12-10T16:32:00.000
2
0
1
0
python,oop,constructor
4,411,085
4
false
0
0
Don't bother, it's not the Python way. The preferred solution is to simply document which constructor or factory method clients are supposed to call, and not worry too much about public/private (which doesn't mean much in Python anyway; everything is essentially public-in-code.)
3
3
0
I'd like to create a factory pattern in Python, where one class has some configuration, and knows how to build another class' object (or several classes) on demand. To make this complete, I would like to prevent the created class from being created outside of the factory. In Java, I would put both in the same package...
How do I create a package protected constructor in Python?
0.099668
0
0
1,476
4,411,044
2010-12-10T16:32:00.000
1
0
1
0
python,oop,constructor
4,420,407
4
true
0
0
Based on a comment from Wim, one can name the class of the object to be created starting with a single or double underscore. This way it is clear that the constructor is private, and should not be called directly.
3
3
0
I'd like to create a factory pattern in Python, where one class has some configuration, and knows how to build another class' object (or several classes) on demand. To make this complete, I would like to prevent the created class from being created outside of the factory. In Java, I would put both in the same package...
How do I create a package protected constructor in Python?
1.2
0
0
1,476
4,411,044
2010-12-10T16:32:00.000
3
0
1
0
python,oop,constructor
4,411,073
4
false
0
0
You can't. The Python mentality is often summed up as "we're all grown-ups here"; that is, you can't stop people calling methods, changing attributes, instantiating classes, and so on. Instead, you should make an obvious way to construct an instance of your class and then assume that it will be used.
3
3
0
I'd like to create a factory pattern in Python, where one class has some configuration, and knows how to build another class' object (or several classes) on demand. To make this complete, I would like to prevent the created class from being created outside of the factory. In Java, I would put both in the same package...
How do I create a package protected constructor in Python?
0.148885
0
0
1,476
4,411,980
2010-12-10T18:20:00.000
1
0
1
0
python,urlparse
4,412,049
1
false
0
0
There's no way to force urlsplit to do that. You can, however, wrap it and then do some dirty work to restore case, or copy the source code and do the modification yourself. Or write the function from scratch, of course. I'd go for the second option.
1
0
0
Is there any way to force urlparse's urlsplit function to preserve the case of the str passed in? It preserves the case of the path in the returned tuple, but not of the netloc, and this is important to me. (I know domain names are case-insensitive, but, we're doing some A/B testing with different capitalizations of th...
Forcing urlparse.urlsplit to preserve str case
0.197375
0
0
326
4,412,253
2010-12-10T18:52:00.000
0
0
0
0
python,css,css-selectors,lxml
4,413,303
2
false
0
0
I don't think CSS selectors have "anything but" selection, so you can't do it that way. Maybe you can do it with XPaths. which are more flexible, but even then you will get very complex and obtuse path expressions. I'd recommend that you simply get all <li> elements, go through each elemnts children, and skip it if one...
1
0
0
I'd like to select an element which has no children of a specific type, for example: all <li> elements who have no <table class="someclass"> children, I'd like to select only the parent element, not the children that don't match table. On a similar note, I'd like to match elements whose parents don't match X, for examp...
CSS Selectors: select element where (parent|children) don't match X
0
0
1
2,018
4,413,692
2010-12-10T22:02:00.000
0
0
0
0
python
4,413,768
2
false
0
1
Most python guis I recommend tkinter but drag 'n drop isn't built into tkinter yet and I'm not a huge fan of the other libraries. Have you thought about IronPython in .Net and WPF? You'll need to learn the xaml syntax but it's not much harder than html (technically, it's stricter and simpler but you need to learn some ...
2
1
0
I have done coding for mathematical simulation of Theory of Computation concepts in Python such as grammar checking and other stuff. My Problem is that I have to build a decent looking GUI for it . I have looked at PyQt4 and the lack of documentation is really a big deterrent. I have looked at other graphical libraries...
Interlinking GUI in some other language and Python
0
0
0
77
4,413,692
2010-12-10T22:02:00.000
1
0
0
0
python
4,413,875
2
true
0
1
I'd look again at PyQT4 if you want something decent looking. PyQt has an an example directory in the source code. KDE uses QT and they have a lot examples too. You have to understand that it is a binding against QT4. When I use it with python I usually just have the QT docs open. Its pretty easy to translate. You cou...
2
1
0
I have done coding for mathematical simulation of Theory of Computation concepts in Python such as grammar checking and other stuff. My Problem is that I have to build a decent looking GUI for it . I have looked at PyQt4 and the lack of documentation is really a big deterrent. I have looked at other graphical libraries...
Interlinking GUI in some other language and Python
1.2
0
0
77
4,413,763
2010-12-10T22:12:00.000
13
0
0
0
java,python
4,413,778
2
true
1
0
JYthon is a python implementation in java , you should check it out www.jython.org
1
0
0
I have a class that is written in Java. Can it be used in Python so i dont have to rewrite it?
Python in java, is it possible
1.2
0
0
286
4,413,840
2010-12-10T22:23:00.000
0
1
0
0
php,python,mysql,phpmyadmin
4,413,898
3
false
0
0
What can I say? Just download the various software, dig in and ask questions here when you run into specific problems.
1
0
0
The question pretty much says it all. The database is in MySQL using phpMyAdmin. A little background: I'm writing the interface for a small non-profit organization. They need to be able to see which customers to ship to this month, which customers have recurring orders, etc. The current system is ancient, written ...
I have a MySQL database, I want to write an interface for it using Python. Help me get started, please!
0
1
0
186
4,413,912
2010-12-10T22:35:00.000
2
0
1
0
python
4,413,920
6
false
0
0
It is now a function in Python 3.
3
13
0
Why is print a keyword in python and not a function?
Why is print not a function in python?
0.066568
0
0
5,322
4,413,912
2010-12-10T22:35:00.000
1
0
1
0
python
4,415,149
6
false
0
0
An answer that draws from what I appreciate about the print statement, but not necessarily from the official Python history... Python is, to some extent, a scripting language. Now, there are lots of definitions of "scripting language", but the one I'll use here is: a language designed for efficient use of short or in...
3
13
0
Why is print a keyword in python and not a function?
Why is print not a function in python?
0.033321
0
0
5,322
4,413,912
2010-12-10T22:35:00.000
1
0
1
0
python
4,413,936
6
false
0
0
The print statement in Python 2.x has some special syntax which would not be available for an ordinary function. For example you can use a trailing , to suppress the output of a final newline or you can use >> to redirect the output to a file. But all this wasn't convincing enough even to Guido van Rossum himself to...
3
13
0
Why is print a keyword in python and not a function?
Why is print not a function in python?
0.033321
0
0
5,322
4,414,102
2010-12-10T23:06:00.000
3
0
1
0
python,user-interface
4,414,119
2
true
0
0
To keep the command window from opening, you can save it as a .pyw file, as opposed to the usual .py. As for converting to exe, py2exe works best for me, I know there are several others, but not as fully developed as py2exe is. Python.org should contain a list of most modules. The same results could easily be procured ...
1
0
0
ok so for the past two weeks or so, ive been learning python as it is extremely simple to comprehend and a very handy method of creating a GUI for a program. However i have three problems. First, when i open my .py file a command window opens , and then my program opens on top of that. Is there a way to just open the ...
Python: Two Windows Opening
1.2
0
0
324
4,414,484
2010-12-11T00:35:00.000
2
0
1
1
python,macos,usb,portability,interpreter
4,414,652
2
false
0
0
Python is already on OS X. I would look at trying to find an editor/shell that will work from a usb drive.
1
2
0
I've been running myself ragged trying to find a portable interpreter that I can run from a USB key on my work computer. Work comp is running Mac OS X 10.6, fairly restricted environment, no access to terminal, can't install apps but I do know that portable apps can be run from a USB drive. I've been using shell in a...
Is there a portable python interpreter that will run on Mac OS X 10.6 from a USB key?
0.197375
0
0
5,446
4,414,611
2010-12-11T01:07:00.000
1
0
0
0
python,blocking,websocket,httpserver
15,036,544
1
false
0
0
WebSockets aren't HTTP, so you can't really handle them with an HTTP request handler. However, using BaseHTTPRequestHandler with HTTP, you would normally be reading only the exact amount of data you expect (for instance, as specified in the Content-length header.)
1
0
0
I'm using Python's BaseHTTPRequestHandler class to build a web server. I want to add an endpoint for WebSockets. This means that I need to read whatever is available from the handler's rfile, so that I can process messages one by one, as I'm receiving them (instead of having to read the while input). I tried using di...
Python, BaseHTTPRequestHandler: how to read what's available on file from socket?
0.197375
0
1
1,273
4,415,259
2010-12-11T04:49:00.000
5
0
1
0
python,string
63,761,973
12
false
0
0
Just format like that: s = "your string"; raw_s = r'{0}'.format(s)
4
87
0
I have a string s, its contents are variable. I'd like to make it a raw string. How do I go about this? Something similar to the r'' method.
Convert regular Python string to raw string
0.083141
0
0
152,678
4,415,259
2010-12-11T04:49:00.000
22
0
1
0
python,string
4,415,275
12
false
0
0
raw strings apply only to string literals. they exist so that you can more conveniently express strings that would be modified by escape sequence processing. This is most especially useful when writing out regular expressions, or other forms of code in string literals. if you want a unicode string without escape pro...
4
87
0
I have a string s, its contents are variable. I'd like to make it a raw string. How do I go about this? Something similar to the r'' method.
Convert regular Python string to raw string
1
0
0
152,678
4,415,259
2010-12-11T04:49:00.000
72
0
1
0
python,string
4,415,585
12
false
0
0
Raw strings are not a different kind of string. They are a different way of describing a string in your source code. Once the string is created, it is what it is.
4
87
0
I have a string s, its contents are variable. I'd like to make it a raw string. How do I go about this? Something similar to the r'' method.
Convert regular Python string to raw string
1
0
0
152,678
4,415,259
2010-12-11T04:49:00.000
32
0
1
0
python,string
58,416,888
12
false
0
0
Since strings in Python are immutable, you cannot "make it" anything different. You can however, create a new raw string from s, like this: raw_s = r'{}'.format(s)
4
87
0
I have a string s, its contents are variable. I'd like to make it a raw string. How do I go about this? Something similar to the r'' method.
Convert regular Python string to raw string
1
0
0
152,678