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 things like this, because the Django people won’t be changing this approach. You could also, however, do something silly (in that it’d be contradictory to the philosophy of the chosen software), like put all the markup and anything else you can into the "view" files, turning Django from its "MVC" (or "MTV" ) paradigm into roughly what everything else is (a boring but straightforward lump).
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 very well. I'm still having trouble getting the whole "dot" notation working as I would expect (for example, {{mydict.dictkey}} inside a for loop doesn't work :S -- I might ask this as a separate question), and I don't see why it wouldn't be possible to just use python code in a template system. In particular, I feel that if templates are meant to be simple, then the level of python code that would need to be employed in these templates would be of a caliber not more complicated than the current templating language. So these designer peeps wouldn't have more trouble learning that much python than they would learning the Django template language (and there's more places you can go with this knowledge of basic python as opposed to DTL) And the added advantage would be that people who already know python would be in familiar territory with all the usual syntax and power available to them and can just get going. Am I missing something? If so I plead django noob and would love for you to enlighten me on the many merits of the current system. But otherwise, any recommendations on other template systems that may be more what I'm looking for?
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 is a designer. Otherwise, let each do his job, with least interference.
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 very well. I'm still having trouble getting the whole "dot" notation working as I would expect (for example, {{mydict.dictkey}} inside a for loop doesn't work :S -- I might ask this as a separate question), and I don't see why it wouldn't be possible to just use python code in a template system. In particular, I feel that if templates are meant to be simple, then the level of python code that would need to be employed in these templates would be of a caliber not more complicated than the current templating language. So these designer peeps wouldn't have more trouble learning that much python than they would learning the Django template language (and there's more places you can go with this knowledge of basic python as opposed to DTL) And the added advantage would be that people who already know python would be in familiar territory with all the usual syntax and power available to them and can just get going. Am I missing something? If so I plead django noob and would love for you to enlighten me on the many merits of the current system. But otherwise, any recommendations on other template systems that may be more what I'm looking for?
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 add new language features, classes, etc. to X by writing them in X than to extend the compiler/interpreter itself.
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 COULD IT BE? The unique explanation that I came up with after thinking a bit is: python is at the same "level" of ASM, it makes sense to python interpret any language (that is in a higher level), am I right? Does this make sense? I would be grateful is someone explain me a little about it. Thank you
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. But the main development of Python is still based on C.
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 COULD IT BE? The unique explanation that I came up with after thinking a bit is: python is at the same "level" of ASM, it makes sense to python interpret any language (that is in a higher level), am I right? Does this make sense? I would be grateful is someone explain me a little about it. Thank you
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 things, and ideally, I'd love to write a symmetric_dict where s_d[v1][v2] always equals s_d[v2][v1], probably by checking which of the v's is larger according to some kind of ordering relation and then switching them around so that the smaller element one is always mentioned first. i.e. when calling s_d[5][2] = 4, the dict of dicts will turn them around so that they are in fact stored as s_d[2][5] = 4, and the same for retrieval of the data. I'm also very open for a better data structure, but I'd prefer an implementation with "is-a" relationship to something which just uses a dict and preprocesses some function arguments.
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 mainpanel doesnt work. please help i really need to find a solution to this its making me mad! p.s. binding everychild to the wx.EVT_LEFT_DOWN is not an option i have hundreds of children i really dont want to go that route
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 the correct wxPython for your Python and OS (32/64 bit), uninstall the current one and install the new one. I've been using wxPython on Windows XP, Vista and 7 with no problems like this.
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 wxPython 2.8.11, all come from their main website, still no luck. Is there something I must do after install Python in Windows ? I can see that python install just fine and can do some basic job, wxPython library can be load, but can't call wx.App
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 wxPython 2.8.11, all come from their main website, still no luck. Is there something I must do after install Python in Windows ? I can see that python install just fine and can do some basic job, wxPython library can be load, but can't call wx.App
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 when I did a reload of the module, python crash. I added this line in the end of the simple.py file: del app and that fixed the problem on windows 7 and tomorrow I try it on the XP machine. Same solution fitted for the XP machine. So, reloading an un-edited module with a reference to a wx.App with a closed gui seem not to be feasable. Killing the reference with a del statement was enough to solve the problem.
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 wxPython 2.8.11, all come from their main website, still no luck. Is there something I must do after install Python in Windows ? I can see that python install just fine and can do some basic job, wxPython library can be load, but can't call wx.App
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 web framework. Django is okay. Others are good too. Learn the web framework. Don't start with your game. Start with the tutorials. Step 4. Rethink your game. Be sure that it fits the framework's model, as well as the HTTP model. Be sure that the game is still good. In particular, if your focus is "more about data models than graphics" then you have to really be sure that your game's data model fits your framework's capabilities. Step 5. Rethink your framework. Is Django still the right choice? Perhaps you need to go back to step 3 and learn another framework. There's nothing wrong with learning a second framework. Indeed, until you learn another framework, you won't fully get Django. Step 6. Now you should have enough background to actually implement your game.
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 future. Please give your invaluable suggestions and recommend some resources with which I can get started.
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 soap libraries due to some previous issues I've had with php. Yes, I would very much like to to be SOAP as this is destined to primarily provide data to a Silverlight client, and VS makes it dead simple to work with soap services. And no, it can't be an WCF service as all of the hosts are linux-based. Much appreciated.
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 streamlined but is unavoidable since, for security reasons, browsers do not allow the server to preselect a value for an <input type="file">.
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 File" lost its value!!! It doesn't have the file picked anymore. THe user is now required to select the file again. This sucks!!
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. Both these can give you a hint without knowing anything about python. If you just want to use yappi, it isn't too much work to set up a virtualbox and install some sort of Linux on your machine. I find myself doing that from time to time when I want to try something. There might of course be things I don't know about that makes it impossible or not worth the effort. Also, profiling on another OS running virtualized might not give the exact same results, but it might still be helpful.
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 to do a non-blocking read on your serial port. If there is data, read it. If not, return to the main event loop. You then need to configure the event loop to poll your port every few hundred milliseconds or so, depending on your performance needs.
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 every check if a button has been pressed. I have tried update_idletasks() and time.sleep(1) with no success. Any suggestions?
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 would always just overwrite it when it makes a 'PUT' to the server.
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 with Outlook 2007. I can currently read an icalendar but it sets that calendar in Outlook 2007 to read only. Doing some searching I've come across some findings saying that setting up some webdav server stuff on a Windows machine I can get the machine to tell Outlook 2007 that the calendar can be editted as well (basically turn off the read only and allow that icalendar to be published). I'm currently trying to set the server up to work with but thought I might ask SO to speed up my research a bit. My question basically is, is there some header information or something else that I can send in my response back to Outlook to let it know an Internet calendar has write privaleges? I know in general it is controlled by the client whether an icalendar can be written to since I can read and write these same calendars just fine in Thunderbird. Additionally, I have heard this read/write problem with Internet calendars have been solved in Outlook 2010 but upgrading to that is not an option.
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 files in wb mode.
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 did: First, i created a temporary file in 'wb' mode, and allowed each connections/threads to dump their chunks. But everytime a connection does this, it overwrites previously saved chunks. I figured this was because i used the 'wb' file descriptor. I changed it to 'ab', but i can no longer perform seek() operations What i am looking for: I need an elegant way of re-packaging this chunk to the original file. I would like to know how other download managers do it. Thank in advance.
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 kb to disk, and go back to sleep.
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 did: First, i created a temporary file in 'wb' mode, and allowed each connections/threads to dump their chunks. But everytime a connection does this, it overwrites previously saved chunks. I figured this was because i used the 'wb' file descriptor. I changed it to 'ab', but i can no longer perform seek() operations What i am looking for: I need an elegant way of re-packaging this chunk to the original file. I would like to know how other download managers do it. Thank in advance.
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. You may also be able to use the Channel API to have a background task send messages directly to the browser, but I'm not sure if this will work or not (I haven't tried it). If you give a little more information about exactly what you're trying to accomplish I can try to give more details about how to get it done.
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? I also installed the gnuplot-python package in case I can do it via a python script.However, I couldn't find the api so it's a bit difficult to figure out. Thank you!
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 given execution environment.
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 actual working multithreading in python?
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 narrow native call, you get concurrency, native performance where it counts, and the convenience of writing most of the code in Python. Not all code has those small, isolatable blocks of computational code that can be neatly implemented in a native library, but a whole lot do.
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 actual working multithreading in python?
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 opinion.
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 language with big fan following (like php for server scripting, JS for client side; c c++ for systems etc).
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 language with big fan following (like php for server scripting, JS for client side; c c++ for systems etc).
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) won't confuse you.
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 Modula-2 with objects, but dynamically typed, of course.
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. The default values of null and blank are False. That being said, it is perfectly fine to have a field with null=True and blank=False. Meaning on the database level the field can be NULL, but in the application level it is a required field. Now, where most developers get it wrong: Defining null=True for string-based fields such as CharField and TextField. Avoid doing that. Otherwise, you will end up having two possible values for “no data”, that is: None and an empty string. Having two possible values for “no data” is redundant. The Django convention is to use the empty string, not NULL.
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=true, NULL is fed into the DB. Now this might throw an error if that particular column in the DB is specified as NOT NULL.
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 about README.
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 your interpreter.
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 from the parameter table by 'del g' AND delete the .pyc file from the directory. It didn't help. when I reimported the function 'from M import g' the old g was loaded).
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 value to a char* variable.
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 value to a char* variable.
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 symlinking (or copying) stuffs to pypy-1.4/site-packages work. And: Do you have NLTK running with PyPy, and if so are you seeing performance improvements? Yes, and yes. So apparently NLTK does run with PyPy and there are performance improvements.
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) and display raw HTML that the script outputs.
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 as such I don't think the Django (or any other python framework) is viable as there would be two competing frameworks running around. I've managed to setup a wsgi-scripts bin and can get python code to run however I have run into a few problems: 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? 2.) When I return from a wsgi/python script a new page is always loaded. Is it possible to have the script return to a div environment? e.g.) Someone fills in a form, submits it, data is processed by python, output is returned and displayed at the bottom of the page. Thanks, Paul
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 standard, it's absolutely all you've got. Outside environment variables." I'm not sure why you're asking, since the standard for HTTP is quite clear and quite simple. 2.) When I return from a wsgi/python script a new page is always loaded. Is it possible to have the script return to a div environment? e.g.) Someone fills in a form, submits it, data is processed by python, output is returned and displayed at the bottom of the page. "have the script return to a div environment" doesn't make any sense at all. "Someone fills in a form, submits it, data is processed by python, output is returned and displayed at the bottom of the page." Doesn't make any sense at all. You seem to be describing something that's not HTTP at all. I'm not sure why you're asking, since the standard for HTTP is quite clear and quite simple. A request (GET, POST, PUT, DELETE, whatever) goes to the web server and a page comes back. That's more-or-less HTTP in a nutshell. There are no other inputs. There are no partial outputs. If you want a Python application (running under mod_wsgi) to get data from Drupal, that's just an API call from Python to whatever server is running Drupal. If you want the old page plus new information to be displayed, you have to assemble a page which contains the old page plus the new information. You have to write this new page. Use a template or some other tool.
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 as such I don't think the Django (or any other python framework) is viable as there would be two competing frameworks running around. I've managed to setup a wsgi-scripts bin and can get python code to run however I have run into a few problems: 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? 2.) When I return from a wsgi/python script a new page is always loaded. Is it possible to have the script return to a div environment? e.g.) Someone fills in a form, submits it, data is processed by python, output is returned and displayed at the bottom of the page. Thanks, Paul
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 expect to get some "stuff" on you.
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 hard time tracking down the answer. Thanks!
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 is, after that it locks the lock, do the stuff it want's to do with the global thing, and finally release the lock. However, don't just use flag variables and if checks to implement this, the threads can switch between the if statement and the locking. Python implements a lock class, if I remember correctly its threading.lock. Also, note that you can run into a deadlock or a livelock if you don't use locks correctly. I don't have much time now so I can't really explain all that here, but you can google that for more info, I'll also check if I can share presentations from my last year's course in university, they explain that pretty good in there.
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 debugging the C# code and try to step into the pyc generated IronPython dll, VS won't allow me to do that. Is there any way for me to be able to step into that code?
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 languages.
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 then if i call a method to his svc file then starts working again. Is there a solution to avoid the idle mode so it can continue to keep the procedure in the loop alive?
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 request.
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 or single column. There's a whole lot of gray area in-between where neither is necessarily better than the other. The other thing to consider is what you said in your question: if you want to show and hide widgets at run-time, grid is probably the best choice because of the grid_remove method which remembers the values of all of the configured attributes in case you want to re-add the widget. Personally, my first choice is always to use pack because I first learned Tk back when there was no grid command. If I can't do it easily in pack, or if I'm very clearly laying things out in a grid, I'll use grid.
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 to show/hide widgets.
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 that it provides. The use of weight (which effects growing and shrinking btw), minsize and maxsize, as well as convenience features like enforcing uniform rows/columns. A fully gridded app of any size will use (significantly) fewer frames than an equivalent packed app, and have better shrink/expand control over inner elements. BTW, both pack and grid can show/hide sub-elements, though the syntax differs slightly between the two. Grid is just slightly better because 'remove' (rather than 'forget') will remember the grid options on the slave widget.
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 to show/hide widgets.
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 to show/hide widgets.
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 statements. If not, I usually notice it shortly afterwards and can do an uncommit if I haven't yet pushed (works for DVCS like git and bzr, not with subversion). Concerning problems that take multiple days, it's just the same thing. I don't commit until the problem is solved and then look at the diff again. A text editor that allows editing within the graphical diff view would be really helpful in these cases, but I'm mostly using Eclipse, which doesn't support that.
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 forget to remove these print/debug alterations. So, my question is: how do you keep yourself organized when doing it? Do you write "TODOs" along the modifications and search for them later, do you keep everything opened in your editor and when you find what you were looking for you just revert the files (This approach isn't useful when you're searching for a really big problem that needs days, you need to turn off your computer and return the other day)? Or you just don't do nothing since print statements in development environment is nothing to worry about? I'm using Vim. I'm just interested to know how other programmers treat this issue.
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 carefully. I am also finding the better way to resolve this issue.
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 forget to remove these print/debug alterations. So, my question is: how do you keep yourself organized when doing it? Do you write "TODOs" along the modifications and search for them later, do you keep everything opened in your editor and when you find what you were looking for you just revert the files (This approach isn't useful when you're searching for a really big problem that needs days, you need to turn off your computer and return the other day)? Or you just don't do nothing since print statements in development environment is nothing to worry about? I'm using Vim. I'm just interested to know how other programmers treat this issue.
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 exceptions, I have arranged to run my code in the Vim buffer with an external interpreter that is set up to automatically enter the debugger on any uncaught exception. Then I'm placed automatically in the code at the point the exception occured. I use a modified debugger that can also signal Vim (actually GTK Gvim) to open that source at that line. Caught exceptions should report meaningful errors, anyway. It is considered by many to be bad practice to do things like: try: ... some code except: handle everything Since you probably aren't actually handling every possible error case. By not doing that you also enable the automatic debugging.
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 forget to remove these print/debug alterations. So, my question is: how do you keep yourself organized when doing it? Do you write "TODOs" along the modifications and search for them later, do you keep everything opened in your editor and when you find what you were looking for you just revert the files (This approach isn't useful when you're searching for a really big problem that needs days, you need to turn off your computer and return the other day)? Or you just don't do nothing since print statements in development environment is nothing to worry about? I'm using Vim. I'm just interested to know how other programmers treat this issue.
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 vcvarsall.bat. For instance, on the 64 bit Windows typical installation paths for these files in Visual Studio 2010 are C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat Or do I just need to install an older version of Visual Studio? If you use official Python builds then you have to install an older version - Visual Studio 2008 or 2005 depending on what version of Python you use. That's because these versions of Visual Studio are used to make official Python builds and you have to use the same version of compiler when building C extension modules.
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 problem would probably be to add the path to the batch file right to my path. However, when looking for that path, 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 "vavarsall.bat". Is it possible to get the setup script to use vcvars32? This is probably ridiculous and may reveal how little I know about batch files, but could I perhaps copy and rename the vcvars32.bat file to vcvarsall.bat, or are they too fundamentally different to work properly? Or do I just need to install an older version of Visual Studio? I would really rather not if I could avoid it. I have also been having trouble building with MinGW. Are there any files I need to download first? Thanks in advance, Ken
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 because it sets everything up for you and all you have to worry about is the opengl part. To learn opengl any book is fine. If you have a good background in programming then you should catch on quite easily.
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 rather clear. However Java (and Scala that I'm currently learning), Python ... are way more comfortable. After about 2 years of struggling with C++ without any remarkable success, I turned away from it. Now for Java/Scala/... there are many OpenGL bindings and I would like to choose the right one. On the contrary there are few books on them. Java 3d and/or JOGL books are available but when looking at Scala or Python things aren't that good. What layer/wrapper/binding would you recommend (Java or Scala). Is there a kind of standard ? Is it possible to learn this binding by reading for eyample "OpenGL Superbible" ? If not, can you recommend a book ? Any advice is welcome. If there's a good IDE (plugin), tool, website, tutorial, ... please let me know it.
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 time, careful reconsider whether the advantages will still make the port worth doing
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 main.py file (executable, which uses those myscripts files). Now I try to do: python setup.py sdist But I get: running sdist warning: sdist: missing required meta-data: url reading manifest file 'MANIFEST' creating myscripts-0.1 making hard links in myscripts-0.1... 'file1.py' not a regular file -- skipping hard linking setup.py -> myscripts-0.1 'file2.py' not a regular file -- skipping tar -cf dist/myscripts-0.1.tar myscripts-0.1 gzip -f9 dist/myscripts-0.1.tar removing 'myscripts-0.1' (and everything under it) Files file1.py and file2.py are as regular as other files. Any suggestions?
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 main.py file (executable, which uses those myscripts files). Now I try to do: python setup.py sdist But I get: running sdist warning: sdist: missing required meta-data: url reading manifest file 'MANIFEST' creating myscripts-0.1 making hard links in myscripts-0.1... 'file1.py' not a regular file -- skipping hard linking setup.py -> myscripts-0.1 'file2.py' not a regular file -- skipping tar -cf dist/myscripts-0.1.tar myscripts-0.1 gzip -f9 dist/myscripts-0.1.tar removing 'myscripts-0.1' (and everything under it) Files file1.py and file2.py are as regular as other files. Any suggestions?
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 everything up to the third instance of */. I'm pretty sure the reason is this third instance of */ has code after it, while the first two are by themselves on the line. I'm not sure why this matters, but I'm pretty sure thats why. Any ideas?
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 everything up to the third instance of */. I'm pretty sure the reason is this third instance of */ has code after it, while the first two are by themselves on the line. I'm not sure why this matters, but I'm pretty sure thats why. Any ideas?
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 &gt in the above - I don't know the forum convention for getting on in my answer). (?*...) was not in Python 2.4 but is a good choice if you are using a later version.
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 everything up to the third instance of */. I'm pretty sure the reason is this third instance of */ has code after it, while the first two are by themselves on the line. I'm not sure why this matters, but I'm pretty sure thats why. Any ideas?
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 numeric properties.
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 need the output to look different, as I can even represent dates as integers.
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 @inlineCallbacks decorator in Twisted, which already write code which sorta looks like it's blocking. But, if you have a large library of code which already uses threads, and you want to port it to be event-driven, something like eventlet can save you some typing, since you don't need to insert 'yield's everywhere.. Some people, like the guys behind the EVE online game, think that code written in this style is just better for some things, such as AI code.
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 to reduce the download size the user has to do, application commonly resort to breaking themselves up into multiple DLLs and updating only the relevant DLLs. When you have a Python application you don't have DLLs but you have an even easier option - you can just keep most of your app's logic outside the exe in .pyc files, and update just some of these .pyc files. Now, mind you, .pyc files are easily "decompilable" into Python (a somewhat obfuscated version of your original code), but having an exe made with py2exe isn't much safer, because py2exe is open-source software and packs all the same files inside the exe anyway. To conclude, my suggestion is don't bother. How large can your application be? With today's fast connections, it's easier to just make the user download a whole new version than to invest a lot of time into building partial-update functionality into your program.
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 complelety random. I don't know how accurately this information was collected, and the goal was something else, but I think you get the point. From a technical point of view I would expect nothing else in a network as big as twitter. I am pretty sure the IDs are sharded, which means they are assigned in special reagions or servers. So that for example if your ID equals mudolo 17 I know I have to look on that very server. Or in that very country. Or something. Or maby the server just have their own prefix or residue class for assigning ids when a new user signs up to avoid replication problems. It is also in most cases uncommon, or "not so cool" to leak information as this. Don't ask me why, its just my esperience that comapnies want to show as least information to the outside as possible. This includes not having an reproduceable transparanet id incremention system. It is also vulnerable for some sort of harmful attacks, unwanted crawling, stuff like that. So my point is. There is no way of giving you a reliable answer. And it should not be necessary. You should design your application do deal with eveyr possible situation. If you want to know how big you should make your database field not to get any conflicts. I think integer should be fine for now. (even on 32 bit systems) But always be prepared to upgrade. Especially don't assume that it will stay numeric. Its just a unique string!
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/" + str(user_id) + ".json?count=200" Thanks,
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(':', ''): v for k, v in ori_dict.items() }
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 accomplished.
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 plenty of containers.
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 what I read, but I only have access to simple free apache web hosts. Python works on it because I've tested it but I don't have a whole lot of freedom on it to install different kinds of software and such.
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 safely from within python (or a shell script)?
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 feasible in your case though.
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 safely from within python (or a shell script)?
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 safely from within python (or a shell script)?
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 includes a data type for sets. A set is an unordered collection with no duplicate elements. Basic uses include membership testing and eliminating duplicate entries. Set objects also support mathematical operations like union, intersection, difference, and symmetric difference. Curly braces or the set() function can be used to create sets. Note: to create an empty set you have to use set(), not {}; the latter creates an empty dictionary, a data structure that we discuss in the next section.
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, and make the class' constructor package protected. For regular method names or variables, one can follow the Python convention and use single or double underscores ("_foo" or "__foo"). Is there a way to do something like that for a constructor? Thank you
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, and make the class' constructor package protected. For regular method names or variables, one can follow the Python convention and use single or double underscores ("_foo" or "__foo"). Is there a way to do something like that for a constructor? Thank you
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, and make the class' constructor package protected. For regular method names or variables, one can follow the Python convention and use single or double underscores ("_foo" or "__foo"). Is there a way to do something like that for a constructor? Thank you
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 the name, and need to preserve case.) Thanks.
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 of the children is a table. This will be easily understandable and maintainable, easy to implement, and unless your performance requirements are really extreme and you need to process tens of thousands of pages per second, it will be Fast Enough (tm). Keep it simple.
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 example: all <li> elements who are not descendents of <table class="someclass">. I'm using python, and lxml's cssselect. Thanks!
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 library controls it will instantiate). There are free versions of visual studio for all of this. Another simple way would be to expose a command line or webservice interface to your python routines.
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 in Python and they are not helping me so is there a way that I can write the GUI stuff in some other language and integrate python in it. The problem is that I want mathematical stuff like circles, epsilon on runtime which have drag and drop events available on them. So simply creating an image is not an option. I am sorry for being a little non specific here but the problem is that I am looking for things that can help here. I have asked a question before too for GUI and unfortunately I could'nt find the right answers for it. Is there a way I can get around this problem. Thanks a lot....
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 could look at PyGTK also, but again, it is a binding against GTK.
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 in Python and they are not helping me so is there a way that I can write the GUI stuff in some other language and integrate python in it. The problem is that I want mathematical stuff like circles, epsilon on runtime which have drag and drop events available on them. So simply creating an image is not an option. I am sorry for being a little non specific here but the problem is that I am looking for things that can help here. I have asked a question before too for GUI and unfortunately I could'nt find the right answers for it. Is there a way I can get around this problem. Thanks a lot....
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 in PHP 4, and I'm in charge of upgrading it. I spoke with the creator of the current system, and he agreed that it would be better to just write a new interface. I'm new to Python, SQL and PHP, so this is a big learning opportunity for me. I'm pretty excited. I do have a lot of programming experience though (C, Java, Objective-C), and I don't anticipate any problems picking up Python. So here I am! Thanks in advance for all your help.
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 interactive programs. Such languages tend to allow one-line programs without excessive boilerplate; make keyboard input easier (for instance, by avoiding excessive punctuation); and provide built-in syntax for common tasks (convenience at the possible expense of purity). In Python's case, printing a value is a very common thing to do, especially in interactive mode. Requiring print to be a function seems unnecessarily inconvenient here. There's a significantly lower risk of error with the special syntax that does the right thing 99% of the time.
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 keep it a statement -- he turned print into a function in Python 3.x.
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 by googling python modules. EDIT: Also, as for the gui, I have found that I personally like pyqt and tkinter best.
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 program? (and not the command window) Second, ive been eagerly searching for a simple method of compiling (or "interpreting") my .py filesinto .exe files. ive come across a few people saying that the program called py2exe is the best method, however i cant get it to work... Are there any easier methods for compiling python source codes into executable files? Third, can anyone refer me to a site with a list of modules for python, along with their descriptions and.or examples? this would greatly help me as i tried using the built in help commands in the python command line, but i find that too generic, like it gives the syntax but no examples of what applications each command/module has. P.S: Just wondering, is there a site that offers example programs (and their source codes) that were made with python that i could take a look at to better understand this language? (examples: Python Games, Python GUI applications, Python Questionaires, Any Python Programs/applications that demonstrate the language's usefulness) INFORMATION: OS: WINDOWS 7: Ultimate Edition Python Version: 2.6 Thanks in Advance!
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 box to serve remote access to my comp at home over the web but out of respect for their network integrity I'd prefer not to. I've also just come across ideone.com which seems promising and I plan to give it a go tomorrow. Ideally though, I'd like to have the code running locally. Any help would be greatly appreciated by myself and, I'm sure, a few others that might be in the same situation.
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 different combinations of 'read' (eg. with a big buffer, thinking that it'd return early with less data if less data was available; with no parameter, but then it just means to read until EOF) but couldn't get this to work. I can think of two solutions: To call read(1): to read bytes one by one. I'd rather not do this, as I'm not sure what the buffering semantics are (eg. I wouldn't want a syscall per byte read). To temporally make the file non-blocking, then attempt a read for a chunk of data, then make it blocking, then attempt a read for 1 byte. This seems rather messy. Another option I can think of is to just use non-blocking sockets, but this wouldn't seem to work so well with my current threaded framework. Any ideas of how to get read to return whatever data is available?
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 processing, just prefix it with ur, like ur'somestring'.
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