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
2,725,362
2010-04-27T21:44:00.000
6
0
0
0
python,wxpython,wxwidgets
2,725,392
2
true
0
1
I've never seen wx.EVT_COMMAND_TEXT_ENTER. I have used wx.EVT_TEXT_ENTER though...
1
8
0
I have a (single line) TextCtrl. The user types data into this. When they press enter, the contents of the box need to be extracted so they can be processed. I can't figure out how to catch enter being pressed. According to the docs, with the style wx.TE_PROCESS_ENTER set on my TextCtrl, it should generate a wx.EVT_COMMAND_TEXT_ENTER event when enter is pressed in the box, which I could then catch. However, wx.EVT_COMMAND_TEXT_ENTER seems not to exist (I get "module has no attribute EVT_COMMAND_TEXT_ENTER), so I'm a bit stuck. Googling just gets a couple of hits of people complaining wx.EVT_COMMAND_TEXT_ENTER doesn't work, so I guess I need another way of doing it.
Get text when enter is pressed in a text box in wxPython
1.2
0
0
7,028
2,725,735
2010-04-27T22:56:00.000
0
0
0
0
python,pdf,graphics
2,725,787
6
false
0
1
Creating PDFs is always a pain, it doesn't make sense if you do not aim to lose sanity. With that said, you are aiming to do two completely different things: when you draw to screen you draw into a raster bitmap, while PDFs are mostly dynamic, like HTML. (unlike HTML they are more prone to be the same over different platforms, but that's beside the point) If you really want to do that, the solution might be finding something that outputs PDFs, and then showing the generated PDF on screen at every step. I guess that's the only way to have WYSIWYG results.
2
3
0
I'm looking for an easy-to-use graphics lib for python that can output to screen as well as pdf. So, I would use code to draw some stuff (simple prims like ovals, rectangles, lines and points) to screen and then when things look good, have it output to pdf.
Recommendations for a simple 2D graphics python library that can output to screen and pdf?
0
0
0
9,999
2,725,735
2010-04-27T22:56:00.000
3
0
0
0
python,pdf,graphics
2,725,883
6
false
0
1
If you use Tkinter, you can draw on a Canvas widget, then use its .postscript method to save the contents as a PostScript file, which you can convert to PDF using ps2pdf. postscript(self, cnf={}, **kw) Print the contents of the canvas to a postscript file. Valid options: colormap, colormode, file, fontmap, height, pageanchor, pageheight, pagewidth, pagex, pagey, rotate, witdh, x, y.
2
3
0
I'm looking for an easy-to-use graphics lib for python that can output to screen as well as pdf. So, I would use code to draw some stuff (simple prims like ovals, rectangles, lines and points) to screen and then when things look good, have it output to pdf.
Recommendations for a simple 2D graphics python library that can output to screen and pdf?
0.099668
0
0
9,999
2,725,754
2010-04-27T23:00:00.000
52
0
1
1
python,windows,scheduled-tasks
5,314,695
3
false
0
0
You can use the GUI from the control panel (called "scheduled tasks") to add a task, most of it should be self-explanatory, but there are two things to watch out for: Make sure you fill in C:\python27\python.exe as the program path, and the path to your script as the argument. If you choose Run whether user is logged on or not I get an error: The directory name is invalid (0x87010B). Choosing Run only when user is logged on "solves" this issue. This took me quite a bit to figure out ...
1
46
0
I have a python script which I would like to run at regular intervals. I am running windows 7. What is the best way to accomplish this? Easiest way?
Schedule Python Script - Windows 7
1
0
0
76,799
2,726,176
2010-04-28T00:55:00.000
0
1
0
0
c++,python,c,linux,unix
2,726,201
5
false
0
0
The answer is conditionally "yes". If your languages/environment has interactive keyboard support that offers Key-Down and Key-Up events, then you catch both events and time the difference between them. This would be trivially easy in JavaScript on a web page, which would also be the easiest way to show off your work to a wider audience.
2
4
0
I am working on a project in which I have to develop bio-passwords based on user's keystroke style. Suppose a user types a password for 20 times, his keystrokes are recorded, like holdtime : time for which a particular key is pressed. digraph time : time it takes to press a different key. suppose a user types a password " COMPUTER". I need to know the time for which every key is pressed. something like : holdtime for the above password is C-- 200ms O-- 130ms M-- 150ms P-- 175ms U-- 320ms T-- 230ms E-- 120ms R-- 300ms The rational behind this is , every user will have a different holdtime. Say a old person is typing the password, he will take more time then a student. And it will be unique to a particular person. To do this project, I need to record the time for each key pressed. I would greatly appreciate if anyone can guide me in how to get these times. Editing from here.. Language is not important, but I would prefer it in C. I am more interested in getting the dataset.
Can I get the amount of time for which a key is pressed on a keyboard
0
0
0
3,012
2,726,176
2010-04-28T00:55:00.000
0
1
0
0
c++,python,c,linux,unix
2,726,199
5
false
0
0
If you read from the terminal in conical mode, you can read each keystroke as it's pressed. You won't see keydown keyup events, like you could if you trapped X events, but it's probably easier, especially if you're just running in a console or terminal.
2
4
0
I am working on a project in which I have to develop bio-passwords based on user's keystroke style. Suppose a user types a password for 20 times, his keystrokes are recorded, like holdtime : time for which a particular key is pressed. digraph time : time it takes to press a different key. suppose a user types a password " COMPUTER". I need to know the time for which every key is pressed. something like : holdtime for the above password is C-- 200ms O-- 130ms M-- 150ms P-- 175ms U-- 320ms T-- 230ms E-- 120ms R-- 300ms The rational behind this is , every user will have a different holdtime. Say a old person is typing the password, he will take more time then a student. And it will be unique to a particular person. To do this project, I need to record the time for each key pressed. I would greatly appreciate if anyone can guide me in how to get these times. Editing from here.. Language is not important, but I would prefer it in C. I am more interested in getting the dataset.
Can I get the amount of time for which a key is pressed on a keyboard
0
0
0
3,012
2,727,438
2010-04-28T07:11:00.000
1
0
1
1
python,macos,installation,configure
2,727,510
3
false
0
0
In general, installing Python (or anything directly from the source) when it is already available on your system or when there are package managers that will install it for you, is not a very good idea. I strongly advise you against installing Python manually... Mac OS X 10.6 Snow Leopard comes with Python 2.6 out of the box; if you want a newer version of Python 2.6, then you should install MacPorts, and use: sudo port install python26 python_select You can then use the python_select to toggle between the system's version and MacPort's version. If you are determined to install manually from the source, though, the way to do it would be to run "make distclean" (or untar the code separately again), then run "./configure --help" for a full list of configuration options. It is possible that on Mac OS X, it defaults to something other than /usr/local, in which case you could force it to install in that location by invoking configure with "./configure --prefix=/usr/local".
2
0
0
I'm trying to install Python from source on my Mac. (OS X 10.6.2, Python-2.6.5.tar.bz2) I've done this before and it was easy, but for some reason, this time after ./configure, and make, the sudo make install puts things some things in my home directory instead of in /usr/local/... where I expect. The .py files are okay, but not the .so files... RobsMac Python-2.6.5 $ sudo make install [...] /usr/bin/install -c -m 644 ./Lib/anydbm.py /usr/local/lib/python2.6 /usr/bin/install -c -m 644 ./Lib/ast.py /usr/local/lib/python2.6 /usr/bin/install -c -m 644 ./Lib/asynchat.py /usr/local/lib/python2.6 [...] running build_scripts running install_lib creating /Users/rob/Library/Python creating /Users/rob/Library/Python/2.6 creating /Users/rob/Library/Python/2.6/site-packages copying build/lib.macosx-10.4-x86_64-2.6/_AE.so -> /Users/rob/Library/ Python/2.6/site-packages copying build/lib.macosx-10.4-x86_64-2.6/_AH.so -> /Users/rob/Library/ Python/2.6/site-packages copying build/lib.macosx-10.4-x86_64-2.6/_App.so -> /Users/rob/Library/ Python/2.6/site-packages [...] Later, this causes imports that require those .so files to fail. For example... RobsMac Python-2.6.5 $ python Python 2.6.5 (r265:79063, Apr 28 2010, 13:40:18) [GCC 4.2.1 (Apple Inc. build 5646) (dot 1)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import zlib Traceback (most recent call last):     File "", line 1, in ImportError: No module named zlib Any ideas what is wrong? thanks, Rob
How do I stop Python install on Mac OS X from putting things in my home directory?
0.066568
0
0
819
2,727,438
2010-04-28T07:11:00.000
2
0
1
1
python,macos,installation,configure
2,727,917
3
true
0
0
Doh. I've answered my own question. Recently I created a ~/.pydistutils.cfg file, for some stupid reason. I forgot to delete that file. It's contents were: [install] install_lib = ~/Library/Python/$py_version_short/site-packages install_scripts = ~/bin make install calls setup.py, and this file was overriding the normal setup.py behavior. Rob
2
0
0
I'm trying to install Python from source on my Mac. (OS X 10.6.2, Python-2.6.5.tar.bz2) I've done this before and it was easy, but for some reason, this time after ./configure, and make, the sudo make install puts things some things in my home directory instead of in /usr/local/... where I expect. The .py files are okay, but not the .so files... RobsMac Python-2.6.5 $ sudo make install [...] /usr/bin/install -c -m 644 ./Lib/anydbm.py /usr/local/lib/python2.6 /usr/bin/install -c -m 644 ./Lib/ast.py /usr/local/lib/python2.6 /usr/bin/install -c -m 644 ./Lib/asynchat.py /usr/local/lib/python2.6 [...] running build_scripts running install_lib creating /Users/rob/Library/Python creating /Users/rob/Library/Python/2.6 creating /Users/rob/Library/Python/2.6/site-packages copying build/lib.macosx-10.4-x86_64-2.6/_AE.so -> /Users/rob/Library/ Python/2.6/site-packages copying build/lib.macosx-10.4-x86_64-2.6/_AH.so -> /Users/rob/Library/ Python/2.6/site-packages copying build/lib.macosx-10.4-x86_64-2.6/_App.so -> /Users/rob/Library/ Python/2.6/site-packages [...] Later, this causes imports that require those .so files to fail. For example... RobsMac Python-2.6.5 $ python Python 2.6.5 (r265:79063, Apr 28 2010, 13:40:18) [GCC 4.2.1 (Apple Inc. build 5646) (dot 1)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import zlib Traceback (most recent call last):     File "", line 1, in ImportError: No module named zlib Any ideas what is wrong? thanks, Rob
How do I stop Python install on Mac OS X from putting things in my home directory?
1.2
0
0
819
2,728,289
2010-04-28T09:40:00.000
0
0
0
1
python
2,728,373
3
false
0
0
I think any modern Linux OS has Python installed, so you can just ditribute the .py file if it has no weird dependencies.
2
1
0
i'm newbie for python programming, i'm having a .py file, now what shall i do so i can create an application from .py file and it can be istall and run in any linux pc, i try to packaging it but its just create .tar file where i need python to run it, is it any to do so, thanks
how to create application(exe) from python script for linux
0
0
0
557
2,728,289
2010-04-28T09:40:00.000
2
0
0
1
python
2,728,622
3
false
0
0
Make sure that the main python file has #! /usr/bin/env python as the first line, then make sure it has execute permission set (should be as easy as chmod +x file_name.py).
2
1
0
i'm newbie for python programming, i'm having a .py file, now what shall i do so i can create an application from .py file and it can be istall and run in any linux pc, i try to packaging it but its just create .tar file where i need python to run it, is it any to do so, thanks
how to create application(exe) from python script for linux
0.132549
0
0
557
2,730,752
2010-04-28T15:14:00.000
1
0
0
0
python,python-3.x
2,734,917
4
false
0
0
I believe lxml has been ported to Python 3
2
11
0
I want to use the htmllib module but it's been removed from Python 3.0. Does anyone know what's the replacement for this module?
Replacement for htmllib module in Python 3.0
0.049958
0
1
5,120
2,730,752
2010-04-28T15:14:00.000
1
0
0
0
python,python-3.x
2,732,223
4
false
0
0
I heard Beautiful soup is getting a port to 3.0.
2
11
0
I want to use the htmllib module but it's been removed from Python 3.0. Does anyone know what's the replacement for this module?
Replacement for htmllib module in Python 3.0
0.049958
0
1
5,120
2,730,969
2010-04-28T15:37:00.000
1
0
1
0
python,geometry,intersection,points
2,731,060
6
false
0
0
You may also want to look into the various clipping algorithms used in graphics development. I have used clipping algorithms to solve alot of problems similar to what you are asking here.
4
6
0
In Python, how would one find all integer points common to two circles? For example, imagine a Venn diagram-like intersection of two (equally sized) circles, with center-points (x1,y1) and (x2,y2) and radii r1=r2. Additionally, we already know the two points of intersection of the circles are (xi1,yi1) and (xi2,yi2). How would one generate a list of all points (x,y) contained in both circles in an efficient manner? That is, it would be simple to draw a box containing the intersections and iterate through it, checking if a given point is within both circles, but is there a better way?
Finding all points common to two circles
0.033321
0
0
4,391
2,730,969
2010-04-28T15:37:00.000
1
0
1
0
python,geometry,intersection,points
2,731,095
6
false
0
0
If the locations and radii of your circles can vary with a granularity less than your grid, then you'll be checking a bunch of points anyway. You can minimize the number of points you check by defining the search area appropriately. It has a width equal to the distance between the points of intersection, and a height equal to r1 + r2 - D with D being the separation of the two centers. Note that this rectangle in general is not aligned with the X and Y axes. (This also gives you a test as to whether the two circles intersect!) Actually, you'd only need to check half of these points. If the radii are the same, you'd only need to check a quarter of them. The symmetry of the problem helps you there.
4
6
0
In Python, how would one find all integer points common to two circles? For example, imagine a Venn diagram-like intersection of two (equally sized) circles, with center-points (x1,y1) and (x2,y2) and radii r1=r2. Additionally, we already know the two points of intersection of the circles are (xi1,yi1) and (xi2,yi2). How would one generate a list of all points (x,y) contained in both circles in an efficient manner? That is, it would be simple to draw a box containing the intersections and iterate through it, checking if a given point is within both circles, but is there a better way?
Finding all points common to two circles
0.033321
0
0
4,391
2,730,969
2010-04-28T15:37:00.000
1
0
1
0
python,geometry,intersection,points
32,522,118
6
false
0
0
You're almost there. Iterating over the points in the box should be fairly good, but you can do better if for the second coordinate you iterate directly between the limits. Say you iterate along the x axis first, then for the y axis, instead of iterating between bounding box coords figure out where each circle intersects the x line, more specifically you are interested in the y coordinate of the intersection points, and iterate between those (pay attention to rounding) When you do this, because you already know you are inside the circles you can skip the checks entirely. If you have a lot of points then you skip a lot of checks and you might get some performance improvements. As an additional improvement you can pick the x axis or the y axis to minimize the number of times you need to compute intersection points.
4
6
0
In Python, how would one find all integer points common to two circles? For example, imagine a Venn diagram-like intersection of two (equally sized) circles, with center-points (x1,y1) and (x2,y2) and radii r1=r2. Additionally, we already know the two points of intersection of the circles are (xi1,yi1) and (xi2,yi2). How would one generate a list of all points (x,y) contained in both circles in an efficient manner? That is, it would be simple to draw a box containing the intersections and iterate through it, checking if a given point is within both circles, but is there a better way?
Finding all points common to two circles
0.033321
0
0
4,391
2,730,969
2010-04-28T15:37:00.000
0
0
1
0
python,geometry,intersection,points
2,731,015
6
false
0
0
So you want to find the lattice points that are inside both circles? The method you suggested of drawing a box and iterating through all the points in the box seems the simplest to me. It will probably be efficient, as long as the number of points in the box is comparable to the number of points in the intersection. And even if it isn't as efficient as possible, you shouldn't try to optimize it until you have a good reason to believe it's a real bottleneck.
4
6
0
In Python, how would one find all integer points common to two circles? For example, imagine a Venn diagram-like intersection of two (equally sized) circles, with center-points (x1,y1) and (x2,y2) and radii r1=r2. Additionally, we already know the two points of intersection of the circles are (xi1,yi1) and (xi2,yi2). How would one generate a list of all points (x,y) contained in both circles in an efficient manner? That is, it would be simple to draw a box containing the intersections and iterate through it, checking if a given point is within both circles, but is there a better way?
Finding all points common to two circles
0
0
0
4,391
2,731,022
2010-04-28T15:46:00.000
24
0
1
0
python,comments,interpreter,interpreted-language
2,731,049
11
false
0
0
Comments are usually stripped out in or before the parsing stage, and parsing is very fast, so effectively comments will not slow down the initialization time.
6
75
0
I am asking this because I use Python, but it could apply to other interpreted languages as well (Ruby, PHP, JavaScript). Am I slowing down the interpreter whenever I leave a comment in my code? According to my limited understanding of an interpreter, it reads program expressions in as strings and then converts those strings into code. It seems that every time it parses a comment, that is wasted time. Is this the case? Is there some convention for comments in interpreted languages, or is the effect negligible?
Do comments slow down an interpreted language?
1
0
0
15,646
2,731,022
2010-04-28T15:46:00.000
100
0
1
0
python,comments,interpreter,interpreted-language
2,731,094
11
true
0
0
For the case of Python, source files are compiled before being executed (the .pyc files), and the comments are stripped in the process. So comments could slow down the compilation time if you have gazillions of them, but they won't impact the execution time.
6
75
0
I am asking this because I use Python, but it could apply to other interpreted languages as well (Ruby, PHP, JavaScript). Am I slowing down the interpreter whenever I leave a comment in my code? According to my limited understanding of an interpreter, it reads program expressions in as strings and then converts those strings into code. It seems that every time it parses a comment, that is wasted time. Is this the case? Is there some convention for comments in interpreted languages, or is the effect negligible?
Do comments slow down an interpreted language?
1.2
0
0
15,646
2,731,022
2010-04-28T15:46:00.000
0
0
1
0
python,comments,interpreter,interpreted-language
2,732,070
11
false
0
0
As the other answers have already stated, a modern interpreted language like Python first parses and compiles the source into bytecode, and the parser simply ignores the comments. This clearly means that any loss of speed would only occur at startup when the source is actually parsed. Because the parser ignores comments, the compiling phase is basically unaffected by any comments you put in. But the bytes in the comments themselves are actually being read in, and then skipped over during parsing. This means, if you have a crazy amount of comments (e.g. many hundreds of megabytes), this would slow down the interpreter. But then again this would slow any compiler as well.
6
75
0
I am asking this because I use Python, but it could apply to other interpreted languages as well (Ruby, PHP, JavaScript). Am I slowing down the interpreter whenever I leave a comment in my code? According to my limited understanding of an interpreter, it reads program expressions in as strings and then converts those strings into code. It seems that every time it parses a comment, that is wasted time. Is this the case? Is there some convention for comments in interpreted languages, or is the effect negligible?
Do comments slow down an interpreted language?
0
0
0
15,646
2,731,022
2010-04-28T15:46:00.000
3
0
1
0
python,comments,interpreter,interpreted-language
2,731,492
11
false
0
0
My limited understanding of an interpreter is that it reads program expressions in as strings and converts those strings into code. Most interpreters read the text (code) in the file and produce an Abstract Syntax Tree data structure, since it can be easily read by the next stage of compilation. That structure contains no code, in text form, and of course no comments either. Just that tree is enough for executing programs. But interpreters, for efficiency reasons, go one step further and produce byte code. And Python does exactly that. We could say that the code and the comments, in the form you wrote them, are simply not present, when the program is running. So no, comments do not slow down the programs at run-time. Note: Interpreters that do not use some other inner structure to represent the code other than text, ie a syntax tree, must do exactly what you mentioned. Interpret again and again the code at run-time.
6
75
0
I am asking this because I use Python, but it could apply to other interpreted languages as well (Ruby, PHP, JavaScript). Am I slowing down the interpreter whenever I leave a comment in my code? According to my limited understanding of an interpreter, it reads program expressions in as strings and then converts those strings into code. It seems that every time it parses a comment, that is wasted time. Is this the case? Is there some convention for comments in interpreted languages, or is the effect negligible?
Do comments slow down an interpreted language?
0.054491
0
0
15,646
2,731,022
2010-04-28T15:46:00.000
5
0
1
0
python,comments,interpreter,interpreted-language
2,731,178
11
false
0
0
It depends on how the interpreter is implemented. Most reasonably modern interpreters do at least a bit of pre-processing on the source code before any actual execution, and that will include stripping out the comments so they make no difference from that point onward. At one time, when memory was severely constrained (e.g., 64K total addressable memory, and cassette tapes for storage) you couldn't take things like that for granted. Back in the day of the Apple II, Commodore PET, TRS-80, etc., it was fairly routine for programmers to explicitly remove comments (and even white-space) to improve execution speed. This was also only one of many source code-level hacks routinely employed at the time1. Of course, it also helped that those machines had CPUs that could only execute one instruction at a time, had clock speeds around 1 MHz, and had only 8-bit processor registers. Even a machine you'd now find only in a dumpster is so much faster than those were that it's not even funny... 1. For another example, in Applesoft you could gain or lose a little speed depending on how you numbered lines. If memory serves, the speed gain was when the target of a goto statement was a multiple of 16.
6
75
0
I am asking this because I use Python, but it could apply to other interpreted languages as well (Ruby, PHP, JavaScript). Am I slowing down the interpreter whenever I leave a comment in my code? According to my limited understanding of an interpreter, it reads program expressions in as strings and then converts those strings into code. It seems that every time it parses a comment, that is wasted time. Is this the case? Is there some convention for comments in interpreted languages, or is the effect negligible?
Do comments slow down an interpreted language?
0.090659
0
0
15,646
2,731,022
2010-04-28T15:46:00.000
2
0
1
0
python,comments,interpreter,interpreted-language
2,731,087
11
false
0
0
Having comments will slow down the startup time, as the scripts will get parsed into an executable form. However, in most cases comments don't slow down runtime. Additionally in python, you can compile the .py files into .pyc, which won't contain the comments (I should hope) - this means that you won't get a startup hit either if the script is already compiled.
6
75
0
I am asking this because I use Python, but it could apply to other interpreted languages as well (Ruby, PHP, JavaScript). Am I slowing down the interpreter whenever I leave a comment in my code? According to my limited understanding of an interpreter, it reads program expressions in as strings and then converts those strings into code. It seems that every time it parses a comment, that is wasted time. Is this the case? Is there some convention for comments in interpreted languages, or is the effect negligible?
Do comments slow down an interpreted language?
0.036348
0
0
15,646
2,731,545
2010-04-28T16:58:00.000
0
0
1
1
python,installation,setuptools
2,734,263
5
false
0
0
Since setuptools doesn't seem to give an easy solution to this, I've decided to give up on this idea until I release my app with py2exe/InnoSetup.
1
6
0
I'm making a Python package that gets installed with a setup.py file using setuptools. The package includes a GUI, and when it's installed on a Windows machine, I want the installation to make a folder in "Programs" in the start menu, and make a shortcut there to a pyw script that will start the GUI. (The pyw think works on all platforms, right?) On Mac and Linux, I would like it to put this shortcut in whatever Mac and Linux have that is parallel to the start menu. How do I do this?
Having my Python package install shortcuts in Start menu
0
0
0
2,198
2,731,871
2010-04-28T17:44:00.000
1
0
0
0
python,mysql,logging,web-applications
2,731,905
2
false
1
0
You can encode the expiration time as part of your session id. Then when you validate the session id, you can also check if it has expired, and if so force the user to log-in again. You can also clean your database periodically, removing expired sessions.
1
1
0
I have a web application in python wherein the user submits their email and password. These values are compared to values stored in a mysql database. If successful, the script generates a session id, stores it next to the email in the database and sets a cookie with the session id, with allows the user to interact with other parts of the sight. When the user clicks logout, the script erases the session id from the database and deletes the cookie. The cookie expires after 5 hours. My concern is that if the user doesnt log out, and the cookie expires, the script will force him to login, but if he has copied the session id from before, it can still be validated. How do i automatically delete the session id from the mysql database after 5 hours?
Automatic logout in python web app
0.099668
0
0
646
2,732,407
2010-04-28T19:06:00.000
1
1
0
0
python,mysql,email,reminders
2,733,383
3
false
0
0
A cronjob every minute or so would do it. If you're considering this, you might like to mind two things: 1 - How many e-mails are expected to be sent per minute? If it takes you 1 second to send an e-mail and you have 100 e-mails per minute, you won't finish your queue. 2 - What will happen if one job starts before the last one finishes? Be careful not to send e-mails twice. You need either to make sure first process ends (risk: you can drop an e-mail eventually), avoid next process to start (risk: first process hangs whole queue) or make them work in parallel (risk: synchronization problems). If you take daramarak's suggestion - make you script add a new cron job at end - you have the risk of whole system colapsing if one error occurs.
2
1
0
I have written up a python script that allows a user to input a message, his email and the time and they would like the email sent. This is all stored in a mysql database. However, how do I get the script to execute on the said time and date? will it require a cron job? I mean say at 2:15 on april 20th, the script will search the database for all times of 2:15, and send out those emails. But what about for emails at 2:16? I am using a shared hosting provided, so cant have a continously running script. Thanks
Timed email reminder in python
0.066568
0
0
2,308
2,732,407
2010-04-28T19:06:00.000
2
1
0
0
python,mysql,email,reminders
2,732,645
3
true
0
0
If you cannot have a continuously running script, something must trigger it, so that would have to rely on your OS internals. In a unix environment a cron job, as you self state, would do the trick. Set cron to run the script, and make the script wait for a given time and then continue running and sending until the next email is more than this given time away. Then make your script add a new cron job for a new wakeup time.
2
1
0
I have written up a python script that allows a user to input a message, his email and the time and they would like the email sent. This is all stored in a mysql database. However, how do I get the script to execute on the said time and date? will it require a cron job? I mean say at 2:15 on april 20th, the script will search the database for all times of 2:15, and send out those emails. But what about for emails at 2:16? I am using a shared hosting provided, so cant have a continously running script. Thanks
Timed email reminder in python
1.2
0
0
2,308
2,733,629
2010-04-28T22:46:00.000
8
1
1
0
python,comparison,egg
2,734,885
2
false
0
0
Using eggs does cause a long sys.path, which has to be searched and when it's really long that search can take a while. Only when you get a hundred entries or so is this going to be a problem (but installing a hundred eggs via easy_install is certainly possible).
2
7
0
Are there any disadvantages about using eggs through easy-install compared to the "traditional" packages/modules/libs?
Disadvantage of Python eggs?
1
0
0
688
2,733,629
2010-04-28T22:46:00.000
8
1
1
0
python,comparison,egg
2,733,647
2
true
0
0
One (potential) disadvantage is that eggs are zipped by default unless zip_safe=False is set in their setup() function in setup.py. If an egg is zipped, you can't get at the files in it (without unzipping it, obviously). If the module itself uses non-source files (such as templates) it will probably specify zip_safe=False, but another consequence is that you cannot effectively step into zipped modules using pdb, the Python debugger. That is, you can, but you won't be able to see the source or navigate properly.
2
7
0
Are there any disadvantages about using eggs through easy-install compared to the "traditional" packages/modules/libs?
Disadvantage of Python eggs?
1.2
0
0
688
2,733,971
2010-04-29T00:07:00.000
1
0
1
0
java,python,android,android-scripting
2,734,044
2
false
0
0
Android does not ship with a Python interpreter, nor does it ship with gcc or other compilers. You will need to get an ARM binary from somewhere or cross-compile one yourself. (BTW, I'm assuming ARM, but substitute in whatever architecture you happen to be running).
1
7
0
I want to install a python package from source on android. Is this possible? I tried in the console to run the py install files, but distutils (.core, ccompiler) isn't being found. Is it possible to still install them?
installing python packages on android
0.099668
0
0
2,648
2,735,828
2010-04-29T08:34:00.000
8
0
0
1
python,django,macos,terminal,pdb
2,745,035
3
true
1
0
OK - this works for me I created a ~/.pdbrc and added import os os.system("stty sane") Now each time pdb is run it sets the line settings back to sane. If I fall out to the terminal then I still have to do it manually - but it solves having to quit runserver and reset all the time.
2
9
0
When debugging my django apps I use pdb for interactive debugging with pdb.set_trace(). However, when I amend a file the local django webserver restarts and then I cant see what I type in the terminal, until I type reset. Is there anyway for this to happen automatically? It can be real annoying, having to cancel the runserver and reset and restart it all the time. I'm told it doesn't happen on other OS's (ubuntu) so is there anyway to make it not happen on the Mac? (I'm using Snow Leopard).
Is there anyway to get pdb and Mac Terminal to play nicely?
1.2
0
0
1,601
2,735,828
2010-04-29T08:34:00.000
1
0
0
1
python,django,macos,terminal,pdb
2,743,003
3
false
1
0
The best I've found is doing a reset inside pdb like so: import os; os.system("reset");
2
9
0
When debugging my django apps I use pdb for interactive debugging with pdb.set_trace(). However, when I amend a file the local django webserver restarts and then I cant see what I type in the terminal, until I type reset. Is there anyway for this to happen automatically? It can be real annoying, having to cancel the runserver and reset and restart it all the time. I'm told it doesn't happen on other OS's (ubuntu) so is there anyway to make it not happen on the Mac? (I'm using Snow Leopard).
Is there anyway to get pdb and Mac Terminal to play nicely?
0.066568
0
0
1,601
2,735,968
2010-04-29T09:00:00.000
1
0
0
1
python,eclipse,debugging,google-app-engine,pydev
2,735,992
1
true
1
0
In fact setting a breakpoint in eclipse is very easy. You have two options: In the grey area next to your line numbers, doubleclick or right mouseclick -> toggle breakpoint.
1
3
0
I've got 10+ years in C/C++, and it appears Visual Studio has spoilt me during that time. In Visual Studio, debbuging issimple: I just add a breakpoint to a line of code, and as soon as that code is executed, my breakpoint triggers, at which point I can view a callstack, local/member variables, etc. I'm trying to achieve this functionality under App Engine. I assume that is possible? All the searching I've done to this point has led me to using Pydev in Eclipse. As best I can tell, I am successfully launching my simple 'hello world' program in Debug mode. But the IDE doesn't even seem to have an option to set a breakpoint? I must be missing something. I've googled long and hard about this, but am having no luck. Most results trace back to the same old threads that don't deal directly with my issue. Can anyone shed some light on how you get basic debugging setup using Pydev/Eclipse with App Engine? Alternatively, if there's an easier way to debug App Engine than using Pydev/Eclipse, I'd love to hear about it. Thanks in advance.
How to get debugging of an App Engine application working?
1.2
0
0
865
2,736,144
2010-04-29T09:28:00.000
212
0
1
0
python,string
15,010,678
4
true
0
0
os.path.join(path, '') will add the trailing slash if it's not already there. You can do os.path.join(path, '', '') or os.path.join(path_with_a_trailing_slash, '') and you will still only get one trailing slash.
1
128
0
How can I add a trailing slash (/ for *nix, \ for win32) to a directory string, if the tailing slash is not already there? Thanks!
Python, add trailing slash to directory string, os independently
1.2
0
0
77,371
2,738,290
2010-04-29T14:49:00.000
0
0
0
1
python,sungridengine
3,821,879
1
true
0
0
created a sleep timer which checks every second for access.. after some time (~15s), access is granted and file is usable!
1
0
0
i have a python script, that submits an job to the SGE (Sun Grid Engine). When the job is done i want to access the output file, generated from the SGE job. i see with "ls" in the directory that the file is already existing and the job is done, but python needs about 20-30 seconds to get access to that file... is there a way to detect new created files faster ?? my problem is to differ between "need time to access the file" or "file is not existing" i tried: os.path.exist(path) os.access(path,os.R_OK) does not solve my problem =(
access a file in python that is created from SunGridEngine
1.2
0
0
52
2,738,809
2010-04-29T15:59:00.000
5
0
1
1
python,fork
52,476,456
2
false
0
0
The answer here may not answer the question. The problem is due to fork(). From the example, you seemed want to share data between two Python scripts. Let me explain my view. As of Python 3.8, there is no true Unix's fork() implementation in Windows platform. For the example above to work, a child process must inherit all environment and open file descriptors. I understand that Windows now support Windows Linux Subsystem, but the last i checked it still does not fully implement fork. Cygwin does actually but it is a bit slow. I do not know how, until now, to pass information between two Python scripts using mmap in Windows platform. Use multiprocessing.Queue or multiprocessing.Pipe or multiprocessing.Manager or multiprocessing's shared memory (Value and Array) instead. I believe you could make each Python script to read in content of the to-be-mapped file into Array of characters. Then use your own structure to map the shared memory into a structured data as you do for the to-be-mapped file.
1
4
0
This code works well in Mac/Linux, but not in Windows. import mmap import os map = mmap.mmap(-1, 13) map.write("Hello world!") pid = os.fork() if pid == 0: # In a child process print 'child' map.seek(0) print map.readline() map.close() else: print 'parent' What's the equivalent function of os.fork() on Windows?
What's the equivalence of os.fork() on Windows with Python?
0.462117
0
0
18,954
2,738,904
2010-04-29T16:13:00.000
10
0
1
0
python,memory-management,docstring
2,738,970
2
true
0
0
"I understand that in Python a string is simply an expression and a string by itself would be garbage collected immediately upon return of control to a code's caller" indicates a misunderstanding, I think. A docstring is evaluated once (not on every function call) and stays alive at least as long as the function does. "Does this even matter?" when it comes to optimization is not answered by thinking about it abstractly but by measuring. "Multiple megabytes" of text isn't probably isn't a lot in a memory-intensive application. The solution for saving memory likely lives elsewhere and you can determine whether that is the case by measurement. Python's -OO command line switch removes docstrings.
1
2
0
I understand that in Python a string is simply an expression and a string by itself would be garbage collected immediately upon return of control to a code's caller, but... Large class/method doc strings in your code: do they waste memory by building the string objects up? Module level doc strings: are they stored infinitely by the interpreter? Does this even matter? My only concern came from the idea that if I'm using a large framework like Django, or multiple large open source libraries, they tend to be very well documented with potentially multiple megabytes of text. In these cases are the doc strings loaded into memory for code that's used along the way, and then kept there, or is it collected immediately like normal strings?
Python - do big doc strings waste memory?
1.2
0
0
799
2,738,959
2010-04-29T16:20:00.000
1
0
1
0
python,multithreading,multiprocessing,gil
2,739,022
3
false
0
0
locks are only ever nessecary if you have multiple agents writing to a source. If they are just accessing, locks are not needed (and as you said defeat the purpose of multiprocessing). Are you sure that would crash the system? On a web server using CGI, each request spawns a new process, so it's not unusual to see thousands of simultaneous processes (granted in python one should use wsgi and avoid this), which do not crash the system. I suggest you test your theory -- it shouldn't be difficult to manufacture 10 simultaneous accesses -- and see if your server really does crash.
1
1
0
I want to use Python's multiprocessing to do concurrent processing without using locks (locks to me are the opposite of multiprocessing) because I want to build up multiple reports from different resources at the exact same time during a web request (normally takes about 3 seconds but with multiprocessing I can do it in .5 seconds). My problem is that, if I expose such a feature to the web and get 10 users pulling the same report at the same time, I suddenly have 60 interpreters open at the same time (which would crash the system). Is this just the common sense result of using multiprocessing, or is there a trick to get around this potential nightmare? Thanks
Python - question regarding the concurrent use of `multiprocess`
0.066568
0
0
758
2,739,051
2010-04-29T16:33:00.000
0
0
1
0
python,list,sorting
2,739,102
14
false
0
0
Without sorting the list the only way to really do it is to iterate through the whole list and save the highest two numbers. I think you'd be better off sorting the list.
3
41
0
How can retrieve the two highest item from a list containing 100,000 integers without having to sort the entire list first?
Retrieve the two highest item from a list containing 100,000 integers
0
0
0
41,376
2,739,051
2010-04-29T16:33:00.000
6
0
1
0
python,list,sorting
2,739,090
14
false
0
0
You iterate over the list, maintaining variables that contain the value of the highest and the second highest item encountered thus far. Each new item that is encountered will replace whichever of the two the new item is higher than (if any).
3
41
0
How can retrieve the two highest item from a list containing 100,000 integers without having to sort the entire list first?
Retrieve the two highest item from a list containing 100,000 integers
1
0
0
41,376
2,739,051
2010-04-29T16:33:00.000
0
0
1
0
python,list,sorting
2,739,097
14
false
0
0
Iterating through the entire list is the only way to do it without sorting.
3
41
0
How can retrieve the two highest item from a list containing 100,000 integers without having to sort the entire list first?
Retrieve the two highest item from a list containing 100,000 integers
0
0
0
41,376
2,741,496
2010-04-29T23:53:00.000
11
0
1
1
python,macos,configuration,python-sip
6,278,976
5
false
0
0
/Library/Python/2.6/site-packages/ is indeed the right place (assuming it's Mac OS 10.6 "Snow Leopard" - you didn't mention which). As @diatoid mentioned, check your system path (and make sure you're actually using Python 2.6 by running python -V).
3
29
0
I'm fighting with installation SIP for Python on Mac OS X. Finally after compilation and installation when I run console form folder of SIP (locally) I can import sipconfig, but when I`m in other folder I cant - there is no module called sipconfig. My question is - Where is folder to which I have to copy modules if I want to have them available globally (like "import os"), or how I can check it, because location "/Library/Python/2.6/site-packages/" doesn`t work.
Location of global libraries for Python on Mac?
1
0
0
107,907
2,741,496
2010-04-29T23:53:00.000
11
0
1
1
python,macos,configuration,python-sip
45,022,496
5
false
0
0
For Python 3.5, It's /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
3
29
0
I'm fighting with installation SIP for Python on Mac OS X. Finally after compilation and installation when I run console form folder of SIP (locally) I can import sipconfig, but when I`m in other folder I cant - there is no module called sipconfig. My question is - Where is folder to which I have to copy modules if I want to have them available globally (like "import os"), or how I can check it, because location "/Library/Python/2.6/site-packages/" doesn`t work.
Location of global libraries for Python on Mac?
1
0
0
107,907
2,741,496
2010-04-29T23:53:00.000
-1
0
1
1
python,macos,configuration,python-sip
65,916,097
5
false
0
0
You can designate an additional locations when python starts up by setting the environmental variable PYTHONPATH. If you add to ~/.bashrc or ~/.zscrc (depending on your default shell) something like: PYTHONPATH=/Library/MyPyhonPackages:/Another/Location; export PYTHONPATH Then those locations will be added to "sys.path" whenever python starts up. This will give you additional places to store your own packages or modules.
3
29
0
I'm fighting with installation SIP for Python on Mac OS X. Finally after compilation and installation when I run console form folder of SIP (locally) I can import sipconfig, but when I`m in other folder I cant - there is no module called sipconfig. My question is - Where is folder to which I have to copy modules if I want to have them available globally (like "import os"), or how I can check it, because location "/Library/Python/2.6/site-packages/" doesn`t work.
Location of global libraries for Python on Mac?
-0.039979
0
0
107,907
2,741,507
2010-04-29T23:55:00.000
2
0
0
1
python,linux,deployment,pylons
2,743,196
8
false
1
0
Have a look at Buildout for reproducible deployments.
2
20
0
We have several Python 2.6 applications running on Linux. Some of them are Pylons web applications, others are simply long-running processes that we run from the command line using nohup. We're also using virtualenv, both in development and in production. What is the best way to deploy these applications to a production server? In development we simply get the source tree into any directory, set up a virtualenv and run - easy enough. We could do the same in production and perhaps that really is the most practical solution, but it just feels a bit wrong to run svn update in production. We've also tried fab, but it just never works first time. For every application something else goes wrong. It strikes me that the whole process is just too hard, given that what we're trying to achieve is fundamentally very simple. Here's what we want from a deployment process. We should be able to run one simple command to deploy an updated version of an application. (If the initial deployment involves a bit of extra complexity that's fine.) When we run this command it should copy certain files, either out of a Subversion repository or out of a local working copy, to a specified "environment" on the server, which probably means a different virtualenv. We have both staging and production version of the applications on the same server, so they need to somehow be kept separate. If it installs into site-packages, that's fine too, as long as it works. We have some configuration files on the server that should be preserved (ie. not overwritten or deleted by the deployment process). Some of these applications import modules from other applications, so they need to be able to reference each other as packages somehow. This is the part we've had the most trouble with! I don't care whether it works via relative imports, site-packages or whatever, as long as it works reliably in both development and production. Ideally the deployment process should automatically install external packages that our applications depend on (eg. psycopg2). That's really it! How hard can it be?
A simple Python deployment problem - a whole world of pain
0.049958
0
0
5,069
2,741,507
2010-04-29T23:55:00.000
0
0
0
1
python,linux,deployment,pylons
2,805,604
8
false
1
0
I would use rsync to synchronize outwards from your production "prime" server to the others, and from your "beta test" platform, to your production "prime" server. rsync has the benefit of copying only those files which changed, and copying only parts of files that changed partially, and verifying the integrity and identical content at the end on all machines. An update that gets part way through and is interrupted can easily be continued later, making your deployment more robust. Subversion or Mercurial would not be a bad idea in this case either. Mercurial has the advantage of allowing you to "pull" or "push" instead of just updating from one central source. You might find interesting cases where a decentralized model (mercurial) works better.
2
20
0
We have several Python 2.6 applications running on Linux. Some of them are Pylons web applications, others are simply long-running processes that we run from the command line using nohup. We're also using virtualenv, both in development and in production. What is the best way to deploy these applications to a production server? In development we simply get the source tree into any directory, set up a virtualenv and run - easy enough. We could do the same in production and perhaps that really is the most practical solution, but it just feels a bit wrong to run svn update in production. We've also tried fab, but it just never works first time. For every application something else goes wrong. It strikes me that the whole process is just too hard, given that what we're trying to achieve is fundamentally very simple. Here's what we want from a deployment process. We should be able to run one simple command to deploy an updated version of an application. (If the initial deployment involves a bit of extra complexity that's fine.) When we run this command it should copy certain files, either out of a Subversion repository or out of a local working copy, to a specified "environment" on the server, which probably means a different virtualenv. We have both staging and production version of the applications on the same server, so they need to somehow be kept separate. If it installs into site-packages, that's fine too, as long as it works. We have some configuration files on the server that should be preserved (ie. not overwritten or deleted by the deployment process). Some of these applications import modules from other applications, so they need to be able to reference each other as packages somehow. This is the part we've had the most trouble with! I don't care whether it works via relative imports, site-packages or whatever, as long as it works reliably in both development and production. Ideally the deployment process should automatically install external packages that our applications depend on (eg. psycopg2). That's really it! How hard can it be?
A simple Python deployment problem - a whole world of pain
0
0
0
5,069
2,741,893
2010-04-30T02:05:00.000
4
0
0
0
python,templates,pylons,mako
2,742,016
2
true
1
0
Not sure if this is the Pylons way of doing things but ${request.url} seems to work for me.
1
1
0
I need to know the full url for the current page from within a Mako template file in Pylons. The url will be using in an iframe contained within the page so it needs to be known when the page is being generated rather than after the page hits the server or from the environment. (Not sure if I am communicating that last bit properly)
Url for the current page from a Mako template in Pylons
1.2
0
0
2,612
2,742,329
2010-04-30T04:39:00.000
2
0
1
0
python,datetime
2,742,347
5
false
0
0
The classes in the datetime module will help. You just need to check whether it's after the 15th of the month. If it is, find the 1st of the next month. If it isn't, find the 15th of the current month.
1
3
0
I'm trying to write a little budget program in python. This is my first program I'm writing to learn python. The first step is to calculate how many days until either the 1st or 15th (paydays) depending on today's date. Can someone help me out a little?
Calculating time until 1st or 15th of the month in python
0.07983
0
0
1,693
2,742,980
2010-04-30T07:37:00.000
18
0
1
1
python,virtualenv,yolk
2,744,571
2
true
0
0
Activating a virtualenv works by changing your shell PATH so the virtualenv's bin/ directory is first. This is all it does. This means that when you run "python" it runs the virtualenv's copy of the Python binary instead of your global system python. If you have yolk installed globally, however, the only "yolk" binary on your PATH is /usr/local/bin/yolk or some such; activating the virtualenv doesn't change this (because there's no "yolk" script in your virtualenv bin/ dir). And the /usr/local/bin/yolk script naturally has your system Python interpreter in its shebang line. This is why installing yolk into the virtualenv fixes the problem; because it adds a yolk script in your virtualenv bin/ dir that has the virtualenv's python in its shebang line. If you don't want to install yolk in each virtualenv, you could also just copy the yolk script-wrapper from /usr/local/bin or wherever it is into your virtualenv's bin dir, and manually change the shebang line to point to your virtualenv's python. This won't work with a --no-site-packages virtualenv, though, because the script wrapper then won't be able to find the actual yolk packages it needs to import! If you want to use yolk within a --no-site-packages virtualenv, really your only choice is to install it there.
2
11
0
yolk -l gives me information that I've got 114 packages installed on my Ubuntu 10.04. After creating new virtualenv directory using virtualenv virt_env/virt1 --no-site-packages --clear I switched to that, my prompt changed and then yolk -l gives me again the same 114 packages. What is going on there?
virtualenv yolk problem
1.2
0
0
2,679
2,742,980
2010-04-30T07:37:00.000
0
0
1
1
python,virtualenv,yolk
3,081,902
2
false
0
0
If the problem isnt relating to your path (I suppose it is) delete your lib and scripts folder in your project directory to clear out the virtualenv settings. Recreate the virtual env using the command line you posted. Activate the virtualenv and then install yolk.
2
11
0
yolk -l gives me information that I've got 114 packages installed on my Ubuntu 10.04. After creating new virtualenv directory using virtualenv virt_env/virt1 --no-site-packages --clear I switched to that, my prompt changed and then yolk -l gives me again the same 114 packages. What is going on there?
virtualenv yolk problem
0
0
0
2,679
2,744,530
2010-04-30T12:41:00.000
3
0
1
0
python,matplotlib,parallel-processing,gil
2,744,657
4
false
0
0
I think you'll need to put the graph into a proper Windowing system, rather than relying on the built-in show code. Maybe sticking the .show() in another thread would be sufficient? The GIL is irrelevant - you've got a blocking show() call, so you need to handle that first.
3
2
1
my problem is the GIL of course. While I'm analysing data it would be nice to present some plots in between (so it's not too boring waiting for results) But the GIL prevents this (and this is bringing me to the point of asking myself if Python was such a good idea in the first place). I can only display the plot, wait till the user closes it and commence calculations after that. A waste of time obviously. I already tried the subprocess and multiprocessing modules but can't seem to get them to work. Any thoughts on this one? Thanks Edit: Ok so it's not the GIL but show().
Python: Plot some data (matplotlib) without GIL
0.148885
0
0
737
2,744,530
2010-04-30T12:41:00.000
3
0
1
0
python,matplotlib,parallel-processing,gil
2,744,604
4
false
0
0
This has nothing to do with the GIL, just modify your analysis code to make it update the graph from time to time (for example every N iterations). Only then if you see that drawing the graph slows the analysis code too much, put the graph update code in a subprocess with multiprocessing.
3
2
1
my problem is the GIL of course. While I'm analysing data it would be nice to present some plots in between (so it's not too boring waiting for results) But the GIL prevents this (and this is bringing me to the point of asking myself if Python was such a good idea in the first place). I can only display the plot, wait till the user closes it and commence calculations after that. A waste of time obviously. I already tried the subprocess and multiprocessing modules but can't seem to get them to work. Any thoughts on this one? Thanks Edit: Ok so it's not the GIL but show().
Python: Plot some data (matplotlib) without GIL
0.148885
0
0
737
2,744,530
2010-04-30T12:41:00.000
2
0
1
0
python,matplotlib,parallel-processing,gil
2,744,906
4
false
0
0
It seems like the draw() method can circumvent the need for show(). The only reason left for .show() in the script is to let it do the blocking part so that the images don't disapear when the script reaches its end.
3
2
1
my problem is the GIL of course. While I'm analysing data it would be nice to present some plots in between (so it's not too boring waiting for results) But the GIL prevents this (and this is bringing me to the point of asking myself if Python was such a good idea in the first place). I can only display the plot, wait till the user closes it and commence calculations after that. A waste of time obviously. I already tried the subprocess and multiprocessing modules but can't seem to get them to work. Any thoughts on this one? Thanks Edit: Ok so it's not the GIL but show().
Python: Plot some data (matplotlib) without GIL
0.099668
0
0
737
2,744,632
2010-04-30T13:00:00.000
0
0
0
0
python,django,sqlite,pysqlite
64,263,492
6
false
1
0
Incompatible Django version. Check Django version for solving this error first. I was running on Django==3.0.8 and it was producing an error. Than I ran virtualenv where I have Django==3.1.2 and the error was removed.
1
6
0
I have a django project that uses a sqlite database that can be written to by an external tool. The text is supposed to be UTF-8, but in some cases there will be errors in the encoding. The text is from an external source, so I cannot control the encoding. Yes, I know that I could write a "wrapping layer" between the external source and the database, but I prefer not having to do this, especially since the database already contains a lot of "bad" data. The solution in sqlite is to change the text_factory to something like: lambda x: unicode(x, "utf-8", "ignore") However, I don't know how to tell the Django model driver this. The exception I get is: 'Could not decode to UTF-8 column 'Text' with text' in /var/lib/python-support/python2.5/django/db/backends/sqlite3/base.py in execute Somehow I need to tell the sqlite driver not to try to decode the text as UTF-8 (at least not using the standard algorithm, but it needs to use my fail-safe variant).
Change text_factory in Django/sqlite
0
1
0
4,701
2,746,542
2010-04-30T17:48:00.000
8
0
1
0
python,module,portable-python
2,748,807
2
true
0
0
What does import sys; print sys.path say? It should be the list of directories and zipfiles where Python (portable or otherwise) looks for modules to import. Just copy your modules into one of those directories or zipfiles, or sys.path.append('/whatever/dir') if you have your modules in /whatever/dir and want to keep them there (the latter approach will last only for the current session, be it interactive or a script's execution).
1
6
0
I am running PortablePython_1.1_py2.6.1 on a USB stick. My code relies on some modules that are not preinstalled. Does anyone know whether it is possible to add new modules to a portable python installation? Simply copying in folders into site-lib does not seem to work.
Importing modules on portable python
1.2
0
0
18,489
2,747,017
2010-04-30T19:13:00.000
0
0
1
0
python,visual-studio,visual-studio-2010
2,747,130
4
false
0
0
You can create custom project that will execute a bat file when building. I remember that I used this method to generate a Inoosetup installer so that you should work to run the py2exe script. I have no idea for the rest of the features. The syntax highlighting and the auto-complete should be much more challenging. I would recommend to give a try to Komodo Edit or Eclipse/Pydev. It works out of the box
3
2
0
I would like to know how to use Visual Studio with CPython (the official python.org python interpreter, not IronPython). In particular, I am interested in getting "build" and "run" commands in Visual Studio working. Other features such as color highlighting and auto-complete, I am less concerned about. Also, can the "build" command be made to run py2exe or similar exe packagers?
Running CPython Applications With Visual Studio?
0
0
0
437
2,747,017
2010-04-30T19:13:00.000
1
0
1
0
python,visual-studio,visual-studio-2010
2,747,733
4
false
0
0
Are you trying to build CPython itself? Doesn't it come with project files suitable for use with Visual Studio? (I seem to remember that it did.) If you mean that you want to use CPython but not build it, then just type c:\pythonxx\python.exe into the debugging executable and in the arguments put your script's full path name. Create a makefile project and you can do whatever you want with the build rules to get "build" to function.
3
2
0
I would like to know how to use Visual Studio with CPython (the official python.org python interpreter, not IronPython). In particular, I am interested in getting "build" and "run" commands in Visual Studio working. Other features such as color highlighting and auto-complete, I am less concerned about. Also, can the "build" command be made to run py2exe or similar exe packagers?
Running CPython Applications With Visual Studio?
0.049958
0
0
437
2,747,017
2010-04-30T19:13:00.000
1
0
1
0
python,visual-studio,visual-studio-2010
2,747,097
4
false
0
0
Eclipse and PyDev already provide an excellent development environment for Python. Is there any reason you cannot use them?
3
2
0
I would like to know how to use Visual Studio with CPython (the official python.org python interpreter, not IronPython). In particular, I am interested in getting "build" and "run" commands in Visual Studio working. Other features such as color highlighting and auto-complete, I am less concerned about. Also, can the "build" command be made to run py2exe or similar exe packagers?
Running CPython Applications With Visual Studio?
0.049958
0
0
437
2,747,860
2010-04-30T21:36:00.000
5
0
1
0
python,packaging,py2exe,setuptools,distutils
2,748,218
4
true
0
0
I ended up solving it by giving py2exe the option skip_archive=True. This caused it to put the Python files not in library.zip but simply as plain files. Then I used data_files to put the data files right inside the Python packages.
1
3
0
I have a Python app which includes non-Python data files in some of its subpackages. I've been using the include_package_data option in my setup.py to include all these files automatically when making distributions. It works well. Now I'm starting to use py2exe. I expected it to see that I have include_package_data=True and to include all the files. But it doesn't. It puts only my Python files in the library.zip, so my app doesn't work. How do I make py2exe include my data files?
Having py2exe include my data files (like include_package_data)
1.2
0
0
15,797
2,748,084
2010-04-30T22:37:00.000
4
0
0
1
python,mud
2,748,104
7
false
0
0
MUDs actions are usually performed on 'ticks' rather than immediately - this allows for limited affect of latency and for monster's commands to be inserted in the queue and processed fairly. Personally, I don't like this approach, but pretty much 99% of MUDs use it. You need to design a robust command queue & event queue which can handle both AI and user commands. You can then add "virtual latency" to AI commands which may be predefined or an average of all users latency, or whatever you like.
5
4
0
I'm trying my hand at building a MUD (multiplayer interactive-fiction game) I'm in the design/conceptualizing phase and I've run into a problem that I can't come up with a solution for. I'm hoping some more experienced programmers will have some advice. Here's the problem as best I can explain it. When the player decides to perform an action he sends a command to the server. the server then processes the command, determines whether or not the action can be performed, and either does it or responds with a reason as to why it could not be done. One reason that an action might fail is that the player is busy doing something else. For instance, if a player is mid-fight and has just swung a massive broadsword, it might take 3 seconds before he can repeat this action. If the player attempts to swing again to soon, the game will respond indicating that he must wait x seconds before doing that. Now, this I can probably design without much trouble. The problem I'm having is how I can replicate this behavior from AI creatures. All of the events that are being performed by the server ON ITS OWN, aka not as an immediate reaction to something a player has done, will have to be time sensitive. Some evil monster has cast a spell on you but must wait 30 seconds before doing it again... I think I'll probably be adding all these events to some kind of event queue, but how can I make that event queue time sensitive?
MUD (game) design concept question about timed events
0.113791
0
0
1,814
2,748,084
2010-04-30T22:37:00.000
3
0
0
1
python,mud
2,749,799
7
false
0
0
AI's are clients. They're "part of the server" only in the most distant view. They're actually outside the main game engine. They're specialized clients with no human being. An AI client has the same interface with the server that a human's client would.
5
4
0
I'm trying my hand at building a MUD (multiplayer interactive-fiction game) I'm in the design/conceptualizing phase and I've run into a problem that I can't come up with a solution for. I'm hoping some more experienced programmers will have some advice. Here's the problem as best I can explain it. When the player decides to perform an action he sends a command to the server. the server then processes the command, determines whether or not the action can be performed, and either does it or responds with a reason as to why it could not be done. One reason that an action might fail is that the player is busy doing something else. For instance, if a player is mid-fight and has just swung a massive broadsword, it might take 3 seconds before he can repeat this action. If the player attempts to swing again to soon, the game will respond indicating that he must wait x seconds before doing that. Now, this I can probably design without much trouble. The problem I'm having is how I can replicate this behavior from AI creatures. All of the events that are being performed by the server ON ITS OWN, aka not as an immediate reaction to something a player has done, will have to be time sensitive. Some evil monster has cast a spell on you but must wait 30 seconds before doing it again... I think I'll probably be adding all these events to some kind of event queue, but how can I make that event queue time sensitive?
MUD (game) design concept question about timed events
0.085505
0
0
1,814
2,748,084
2010-04-30T22:37:00.000
2
0
0
1
python,mud
4,190,774
7
false
0
0
You could use threads to handle specific types of Mobs, and put all the instances into an array of some sort. Then, the thread simply goes through the list repeatedly applying logic. DelayTimeStart and Delay could be attributes of the parent Mob class, and when the thread goes through the loop, it can put off processing any instances of the Mob in which there is time remaining in the delay.
5
4
0
I'm trying my hand at building a MUD (multiplayer interactive-fiction game) I'm in the design/conceptualizing phase and I've run into a problem that I can't come up with a solution for. I'm hoping some more experienced programmers will have some advice. Here's the problem as best I can explain it. When the player decides to perform an action he sends a command to the server. the server then processes the command, determines whether or not the action can be performed, and either does it or responds with a reason as to why it could not be done. One reason that an action might fail is that the player is busy doing something else. For instance, if a player is mid-fight and has just swung a massive broadsword, it might take 3 seconds before he can repeat this action. If the player attempts to swing again to soon, the game will respond indicating that he must wait x seconds before doing that. Now, this I can probably design without much trouble. The problem I'm having is how I can replicate this behavior from AI creatures. All of the events that are being performed by the server ON ITS OWN, aka not as an immediate reaction to something a player has done, will have to be time sensitive. Some evil monster has cast a spell on you but must wait 30 seconds before doing it again... I think I'll probably be adding all these events to some kind of event queue, but how can I make that event queue time sensitive?
MUD (game) design concept question about timed events
0.057081
0
0
1,814
2,748,084
2010-04-30T22:37:00.000
0
0
0
1
python,mud
4,879,667
7
false
0
0
A basic approach would be to have a data structure representing the evil monster's instance of its spell, with a cooldown timer on it. When the power is used, the cooldown is set (presumably to a number of seconds defined by the master definition of the spell); an attempt to use it again will fail just like with the player ability. This can be integrated with an event queue by having the queue check cooldown, and if it hasn't expired, to wait for it to expire, or abort the action, or reschedule the action, as appropriate.
5
4
0
I'm trying my hand at building a MUD (multiplayer interactive-fiction game) I'm in the design/conceptualizing phase and I've run into a problem that I can't come up with a solution for. I'm hoping some more experienced programmers will have some advice. Here's the problem as best I can explain it. When the player decides to perform an action he sends a command to the server. the server then processes the command, determines whether or not the action can be performed, and either does it or responds with a reason as to why it could not be done. One reason that an action might fail is that the player is busy doing something else. For instance, if a player is mid-fight and has just swung a massive broadsword, it might take 3 seconds before he can repeat this action. If the player attempts to swing again to soon, the game will respond indicating that he must wait x seconds before doing that. Now, this I can probably design without much trouble. The problem I'm having is how I can replicate this behavior from AI creatures. All of the events that are being performed by the server ON ITS OWN, aka not as an immediate reaction to something a player has done, will have to be time sensitive. Some evil monster has cast a spell on you but must wait 30 seconds before doing it again... I think I'll probably be adding all these events to some kind of event queue, but how can I make that event queue time sensitive?
MUD (game) design concept question about timed events
0
0
0
1,814
2,748,084
2010-04-30T22:37:00.000
0
0
0
1
python,mud
21,559,958
7
false
0
0
I'll provide you an answer from an LPMud/LDMud point of view. Every player in the MUD is an instance of player.c. Player.c inherits from living.c. Things that are living have a heartbeat. The heartbeat function is processed once every 2 seconds for every living object on the mud (or anything that has a heartbeat() function). Timing events is not typically done based on seconds, but instead based on the number of heartbeats that have elapsed through counters within the object. The wonderful news that applies to your question is that monsters also inherit from living.c. This means that if you had actions that can only be performed periodically this can all be managed within the heartbeat based on the number of ticks that have occurred.
5
4
0
I'm trying my hand at building a MUD (multiplayer interactive-fiction game) I'm in the design/conceptualizing phase and I've run into a problem that I can't come up with a solution for. I'm hoping some more experienced programmers will have some advice. Here's the problem as best I can explain it. When the player decides to perform an action he sends a command to the server. the server then processes the command, determines whether or not the action can be performed, and either does it or responds with a reason as to why it could not be done. One reason that an action might fail is that the player is busy doing something else. For instance, if a player is mid-fight and has just swung a massive broadsword, it might take 3 seconds before he can repeat this action. If the player attempts to swing again to soon, the game will respond indicating that he must wait x seconds before doing that. Now, this I can probably design without much trouble. The problem I'm having is how I can replicate this behavior from AI creatures. All of the events that are being performed by the server ON ITS OWN, aka not as an immediate reaction to something a player has done, will have to be time sensitive. Some evil monster has cast a spell on you but must wait 30 seconds before doing it again... I think I'll probably be adding all these events to some kind of event queue, but how can I make that event queue time sensitive?
MUD (game) design concept question about timed events
0
0
0
1,814
2,748,946
2010-05-01T04:57:00.000
2
0
0
0
python,database,postgresql,sqlalchemy,database-schema
2,768,187
4
true
0
0
The solution is rather administrative then technical :) The general rule is easy, there should only be tree-like dependencies in the project: - There should always be a single master source of schema, stored together with the project source code in the version control - Everything affected by the change in the master source should be automatically re-generated every time the master source is updated, no manual intervention allowed never, if automatic generation does not work -- fix either master source or generator, don't manually update the source code - All re-generations should be performed by the same person who updated the master source and all changes including the master source change should be considered a single transaction (single source control commit, single build/deployment for every affected environment including DBs update) Being enforced, this gives 100% reliable result. There are essentially 3 possible choices of the master source 1) DB metadata, sources are generated after DB update by some tool connecting to the live DB 2) Source code, some tool is generating SQL scheme from the sources, annotated in a special way and then SQL is run on the DB 3) DDL, both SQL schema and source code are generated by some tool 4) some other description is used (say a text file read by a special Perl script generating both SQL schema and the source code) 1,2,3 are equally good, providing that the tool you need exists and is not over expensive 4 is a universal approach, but it should be applied from the very beginning of the project and has an overhead of couple thousands lines of code in a strange language to maintain
1
9
0
I'm curious about how others have approached the problem of maintaining and synchronizing database changes across many (10+) developers without a DBA? What I mean, basically, is that if someone wants to make a change to the database, what are some strategies to doing that? (i.e. I've created a 'Car' model and now I want to apply the appropriate DDL to the database, etc..) We're primarily a Python shop and our ORM is SQLAlchemy. Previously, we had written our models in such a way to create the models using our ORM, but we recently ditched this because: We couldn't track changes using the ORM The state of the ORM wasn't in sync with the database (e.g. lots of differences primarily related to indexes and unique constraints) There was no way to audit database changes unless the developer documented the database change via email to the team. Our solution to this problem was to basically have a "gatekeeper" individual who checks every change into the database and applies all accepted database changes to an accepted_db_changes.sql file, whereby the developers who need to make any database changes put their requests into a proposed_db_changes.sql file. We check this file in, and, when it's updated, we all apply the change to our personal database on our development machine. We don't create indexes or constraints on the models, they are applied explicitly on the database. I would like to know what are some strategies to maintain database schemas and if ours seems reasonable. Thanks!
What are some strategies for maintaining a common database schema with a team of developers and no DBA?
1.2
1
0
930
2,750,341
2010-05-01T14:43:00.000
2
1
0
0
python,rest,web.py
2,750,368
4
false
1
0
Instead of calling it /post/52/edit, what if you called it /post/52/editor? Now it is a resource. Dilemma averted.
2
4
0
I'm almost afraid to post this question, there has to be an obvious answer I've overlooked, but here I go: Context: I am creating a blog for educational purposes (want to learn python and web.py). I've decided that my blog have posts, so I've created a Post class. I've also decided that posts can be created, read, updated, or deleted (so CRUD). So in my Post class, I've created methods that respond to POST, GET, PUT, and DELETE HTTP methods). So far so good. The current problem I'm having is a conceptual one, I know that sending a PUT HTTP message (with an edited Post) to, e.g., /post/52 should update post with id 52 with the body contents of the HTTP message. What I do not know is how to conceptually correctly serve the (HTML) edit page. Will doing it like this: /post/52/edit violate the idea of URI, as 'edit' is not a resource, but an action? On the other side though, could it be considered a resource since all that URI will respond to is a GET method, that will only return an HTML page? So my ultimate question is this: How do I serve an HTML page intended for user editing in a RESTful manner?
Is www.example.com/post/21/edit a RESTful URI? I think I know the answer, but have another question
0.099668
0
1
267
2,750,341
2010-05-01T14:43:00.000
4
1
0
0
python,rest,web.py
2,750,379
4
false
1
0
Another RESTful approach is to use the query string for modifiers: /post/52?edit=1 Also, don't get too hung up on the purity of the REST model. If your app doesn't fit neatly into the model, break the rules.
2
4
0
I'm almost afraid to post this question, there has to be an obvious answer I've overlooked, but here I go: Context: I am creating a blog for educational purposes (want to learn python and web.py). I've decided that my blog have posts, so I've created a Post class. I've also decided that posts can be created, read, updated, or deleted (so CRUD). So in my Post class, I've created methods that respond to POST, GET, PUT, and DELETE HTTP methods). So far so good. The current problem I'm having is a conceptual one, I know that sending a PUT HTTP message (with an edited Post) to, e.g., /post/52 should update post with id 52 with the body contents of the HTTP message. What I do not know is how to conceptually correctly serve the (HTML) edit page. Will doing it like this: /post/52/edit violate the idea of URI, as 'edit' is not a resource, but an action? On the other side though, could it be considered a resource since all that URI will respond to is a GET method, that will only return an HTML page? So my ultimate question is this: How do I serve an HTML page intended for user editing in a RESTful manner?
Is www.example.com/post/21/edit a RESTful URI? I think I know the answer, but have another question
0.197375
0
1
267
2,750,911
2010-05-01T17:32:00.000
1
1
0
1
python,unit-testing,google-app-engine
4,059,206
4
false
1
0
Since, gae is based on webhooks it can be easy to set your own testing framework for all relevant urls in your app.yaml. You can test it on sample dataset on development server ( start devel server with --datastore_path option ) and assert writes to database or webhook responses.
1
17
0
I'd like to write some Python unit tests for my Google App Engine. How can I set that up? Does someone happen to have some sample code which shows how to write a simple test?
Google App Engine Python Unit Tests
0.049958
0
0
5,767
2,751,250
2010-05-01T19:10:00.000
3
0
1
0
python
2,751,264
5
true
0
0
A lot of 3rd party Python modules still require Python 2.x (numpy, scipy for example). If you will use any of those, or if you don't yet know what modules you need and want to keep your options open then stick with Python 2.x for now. If you know that all the modules you need work with Python 3.x then go with that.
4
3
0
I'm starting a new Python web project. With most frameworks, everyone rushes to the latest version, however, it seems that this is not as true for Python 3.x. Which version of Python should brand new projects use?
Which version of Python should be used?
1.2
0
0
317
2,751,250
2010-05-01T19:10:00.000
1
0
1
0
python
2,751,924
5
false
0
0
I'd recommend Python 2.6 because it has some features of Python 3.x, but it still retains the same functionality found in Python 2.5. While some might argue that Python 3.x is better (quite possibly because of the immense amount of reorganisation and the fact that all strings are Unicode by default), most Python code in use right now is still for Python 2.x. I'd say stick with Python 2.6 until you need Python 3.x. :)
4
3
0
I'm starting a new Python web project. With most frameworks, everyone rushes to the latest version, however, it seems that this is not as true for Python 3.x. Which version of Python should brand new projects use?
Which version of Python should be used?
0.039979
0
0
317
2,751,250
2010-05-01T19:10:00.000
2
0
1
0
python
2,751,863
5
false
0
0
for a web project, chose the python version that is supported by your hosting provider. if you are lucky to have a dedicated server, then chose whatever version is best supported by the framework you chose. python 3 is still not supported by the major web framework, so python 2.6 seems the best choice. if your project is hosted on a shared host, you will have to stick with the python version installed on the host (personally, i am stuck with python 2.4.4, hoping my hosting provider will upgrade to 2.5 or 2.6, which will not come anytime soon)
4
3
0
I'm starting a new Python web project. With most frameworks, everyone rushes to the latest version, however, it seems that this is not as true for Python 3.x. Which version of Python should brand new projects use?
Which version of Python should be used?
0.07983
0
0
317
2,751,250
2010-05-01T19:10:00.000
0
0
1
0
python
2,751,260
5
false
0
0
I use 2.5 for Google App Engine projects and 2.6 for my Django projects.
4
3
0
I'm starting a new Python web project. With most frameworks, everyone rushes to the latest version, however, it seems that this is not as true for Python 3.x. Which version of Python should brand new projects use?
Which version of Python should be used?
0
0
0
317
2,751,548
2010-05-01T21:11:00.000
2
0
0
1
python,ruby,linux,design-patterns,mvvm
2,751,881
5
false
1
0
Given how you explain your application in a comment, while fully endorsing Qt, I would also recommend you consider the many advantages that could come your way from making your application a web app. Since you say it's a client-server app, it needs (at least) local network connectivity at least, so the first objection typically raised against web apps is nullified. The first huge advantage is that you wouldn't be choosing one client platform vs another -- just support modern cross-platform browsers like Firefox or Google's Chrome, and your customers will be able to pick whatever client platform(s) they prefer (if you also carefully check your app on Safari, which has much rendering logic in common with Chrome via the Webkit framework, your web app will then be usable on iPad too). The second big win is that your app won't require any "installation" on the client(s) -- it will always be ready. Modern Javascript frameworks (such as jQuery, Dojo, Closure, ...) allow heavy interactivity if you need it, support GUI building with UI widgets &c, and incidentally take care of most cross-browser differences on your behalf. On the server side, with either Ruby or Python (or other languages yet), you can even find frameworks that smoothly integrate with the client-side Javascript resources. Oh, and, the computational resources needed to run the application (such as RAM, CPU power, disk space, ...) are cheaper "in bulk" on a server, or small group of servers, and thus shared among those clients which are active at a given time, than spread out over many clients (including many who won't happen to be active at any givem time;-). Really, in my opinion, there is little left today to recommend local GUI apps when you're developing anew anyway, save possibly the need to run when cut off from all connectivity (and, even there, with HTML5 and the like, browsers are making great strides towards empowering such apps).
3
0
0
I am investigating a switch from windows to linux and i struggle to find samples of design patterns applied in this world. The application is a classic client server with detailed forms for each business entity. It will be taking user input, do some validation checks, a few calculations, and save them to database. It will also have lists summarizing entities, and searches among these entities. A click to one item of these lists will open the detailled forms. If i use python or ruby, what should i use for GUI ? And what pattern : is MVC, MVVM or MVP any good ? Or is there anything better ? Note : I have never done web developpement, and i would like to avoid to have to learn both linux and web developpement at the same time.
Validity of GUI design patterns under linux
0.07983
0
0
894
2,751,548
2010-05-01T21:11:00.000
1
0
0
1
python,ruby,linux,design-patterns,mvvm
2,751,596
5
false
1
0
The two main UI toolkits in Linux these days are Qt and GTK+. Qt is widely used by the KDE desktop, while GTK+ is widely used by Gnome. But a Qt app will run in Gnome and vise-versa. Both toolkits have bindings to a massive amount of languages.
3
0
0
I am investigating a switch from windows to linux and i struggle to find samples of design patterns applied in this world. The application is a classic client server with detailed forms for each business entity. It will be taking user input, do some validation checks, a few calculations, and save them to database. It will also have lists summarizing entities, and searches among these entities. A click to one item of these lists will open the detailled forms. If i use python or ruby, what should i use for GUI ? And what pattern : is MVC, MVVM or MVP any good ? Or is there anything better ? Note : I have never done web developpement, and i would like to avoid to have to learn both linux and web developpement at the same time.
Validity of GUI design patterns under linux
0.039979
0
0
894
2,751,548
2010-05-01T21:11:00.000
0
0
0
1
python,ruby,linux,design-patterns,mvvm
2,753,393
5
false
1
0
Design (or architectural) patterns have nothing to do with the target programming language or operating system. Ook at you problem, if you can see you requirements which will be fulfilled by some solution provided by a pattern and the consequences will be good, jsut use the pattern. If you aks MVC, MVP, MVVM etc. look at those patterns and problems they solve and if it is what you need for you application, use them.
3
0
0
I am investigating a switch from windows to linux and i struggle to find samples of design patterns applied in this world. The application is a classic client server with detailed forms for each business entity. It will be taking user input, do some validation checks, a few calculations, and save them to database. It will also have lists summarizing entities, and searches among these entities. A click to one item of these lists will open the detailled forms. If i use python or ruby, what should i use for GUI ? And what pattern : is MVC, MVVM or MVP any good ? Or is there anything better ? Note : I have never done web developpement, and i would like to avoid to have to learn both linux and web developpement at the same time.
Validity of GUI design patterns under linux
0
0
0
894
2,751,957
2010-05-01T23:44:00.000
2
0
0
0
python,mysql,apache,sqlalchemy,fastcgi
2,751,989
2
true
0
0
Looks like SQLalchemy is pushing or echoing the query to your output (where fast-cgi) is instead looking for headers, then body. Maybe setting sqlalchemy.echo to False can help.
1
0
0
I'm writing an Fast-CGI application that makes use of sqlAlchemy & MySQL for persistent data storage. I have no problem connecting to the DB and setting up ORM (so that tables get mapped to classes); I can even add data to tables (in memory). But, as soon as I query the DB (and push any changes from memory to storage) I get a 500 Internal Server Error and my error.log records malformed header from script. Bad header=FROM tags : index.py, when tags is the table name. Any idea what could be causing this? Also, I don't think it matters, but its a Linux development server talking to an off-site (across the country) MySQL server.
Python fCGI + sqlAlchemy = malformed header from script. Bad header=FROM tags : index.py
1.2
1
0
921
2,752,008
2010-05-02T00:10:00.000
0
0
0
1
python,google-app-engine
2,752,566
1
false
1
0
When this has happened to me it's because I've been using a TextField, which cannot be queried (but confusingly just gets ignored). Try switching to StringField.
1
2
0
EDIT: Figured it out. For whatever reason the field in the index was called strWord instead of wordStr. I didn't notice because of the similarities. The file was auto generated, so I must have called the field that in a previous development version. I've got an app with around half a million 'records', each of which only stores three fields. I'd like to look up records by a string field with a query, but I'm running into problems. If I visit the console page, manually view a record and save it (without making changes) it shows up in a query: SELECT * FROM wordEntry WHERE wordStr = 'SomeString' If I don't do this, I get 'no results'. Does appengine need time to update? If so, how much? (I was also having trouble batch deleting and modifying data, but I was able to break the problem up into smaller chunks.)
Appengine (python) returns empty for valid queries
0
0
0
161
2,752,022
2010-05-02T00:27:00.000
4
0
1
0
python,string,email,data-mining,fuzzy-search
2,752,090
2
true
0
0
I would first turn each string of characters into a set or multiset of words (ignoring punctuation and differences in lower/upper case). (If that's not powerful enough, in a second pass I could try pairs or even triples of adjacent words, known as bigrams and trigrams). The key measure of similarity between strings thus reduced is, what words that are not high frequency overall (not the, and, etc;-) are common to both strings, so a simple set intersection (or multiset intersection, but for your simple use case I think just sets would work fine, esp. sets of bigrams) should suffice to measure the "commonality". A word that's common to the two strings should be worth more the rarer it is, so negative log of frequency of the word across the whole corpus is an excellent starting point for this heuristics.
1
3
0
I'm downloading a long list of my email subject lines , with the intent of finding email lists that I was a member of years ago, and would want to purge them from my Gmail account (which is getting pretty slow.) I'm specifically thinking of newsletters that often come from the same address, and repeat the product/service/group's name in the subject. I'm aware that I could search/sort by the common occurrence of items from a particular email address (and I intend to), but I'd like to correlate that data with repeating subject lines.... Now, many subject lines would fail a string match, but "Google Friends : Our latest news" "Google Friends : What we're doing today" are more similar to each other than a random subject line, as is: "Virgin Airlines has a great sale today" "Take a flight with Virgin Airlines" So -- how can I start to automagically extract trends/examples of strings that may be more similar. Approaches I've considered and discarded ('because there must be some better way'): Extracting all the possible substrings and ordering them by how often they show up, and manually selecting relevant ones Stripping off the first word or two and then count the occurrence of each sub string Comparing Levenshtein distance between entries Some sort of string similarity index ... Most of these were rejected for massive inefficiency or likelyhood of a vast amount of manual intervention required. I guess I need some sort of fuzzy string matching..? In the end, I can think of kludgy ways of doing this, but I'm looking for something more generic so I've added to my set of tools rather than special casing for this data set. After this, I'd be matching the occurring of particular subject strings with 'From' addresses - I'm not sure if there's a good way of building a data structure that represents how likely/not two messages are part of the 'same email list' or by filtering all my email subjects/from addresses into pools of likely 'related' emails and not -- but that's a problem to solve after this one. Any guidance would be appreciated.
Algorithm detect repeating/similiar strings in a corpus of data -- say email subjects, in Python
1.2
0
0
768
2,752,047
2010-05-02T00:35:00.000
0
0
0
0
python,database,openfire
2,766,455
1
false
0
0
Openfire uses a SQL database. So talking to the database from python is probably the easiest way. You could also try to connect/authenticate via XMPP - there's probably an xmpp library for python somewhere.
1
0
0
How would one go about authenticating against a single db using Python and openfire? Is there a simple module that will do this?
I need to authenticate against one db with python and openfire. How do I do this?
0
1
0
94
2,752,055
2010-05-02T00:38:00.000
1
0
1
0
python
2,752,070
5
false
0
0
1) Yes, if you grasped the material in your intro to C++ class you should be able to pick up the basics of Python without too much trouble 2) It can be. There's Py2Exe which can include the necessary python files to run standalone. Otherwise Python will need to be installed.
2
1
0
I'm thinking about rewriting an MS Access db I wrote years ago into a stand-alone Python app. Other than a college class called "Intro to C++" (console only, with OOP concepts) and the Access db itself, I have no experience, so I need to ask if the basis for my decision to go with Python is correct. Is it true that: 1) Python is relatively easy to pick up? 2) Python apps can run as "portable" (ie from one directory, no registry needs, nothing needs to be pre-installed on a Windows PC) as long as I use an embedded db?
Python questions from beginner
0.039979
0
0
386
2,752,055
2010-05-02T00:38:00.000
2
0
1
0
python
2,752,156
5
false
0
0
Python is like the game Go, the rules are easy, but it's hard to master. You'll get started easily, but if you wind up using it as an interpreted version of VB, or C, you'll be missing much of the point. More to the point, if your Access application is UI-centric, Python is not necessarily the natural platform to port it to. Python does not specialize, or particularly excel, in building UIs and there's no "visual"-style application builder (that I know of) as in Access. If your application is more oriented towards reading, manipulating, and writing data, however, Python is ideal.
2
1
0
I'm thinking about rewriting an MS Access db I wrote years ago into a stand-alone Python app. Other than a college class called "Intro to C++" (console only, with OOP concepts) and the Access db itself, I have no experience, so I need to ask if the basis for my decision to go with Python is correct. Is it true that: 1) Python is relatively easy to pick up? 2) Python apps can run as "portable" (ie from one directory, no registry needs, nothing needs to be pre-installed on a Windows PC) as long as I use an embedded db?
Python questions from beginner
0.07983
0
0
386
2,752,915
2010-05-02T08:56:00.000
2
0
0
1
python,linux,bash,unix,scripting
2,752,934
2
false
0
0
Use incron to create the symlink, then find -L in cron to break it.
1
2
0
i have a large number of files/folders coming in each day that are being sorted automatically to a wide variety of folders. I'm looking for a way to automatically find these files/folders and create symlinks to them all within an "incoming" folder. Searching for file age should be sufficient for finding the files, however searching for age and owner would be ideal. Then once the files/folders being linked to reach a certain age, say 5 days, remove the symlinks to them automatically from the "incoming" folder. Is this possible to do with a simple shell or python script that can be run with cron? Thanks!
symlink files newer than X age, then later remove symlink once file ages?
0.197375
0
0
465
2,753,966
2010-05-02T15:39:00.000
0
1
0
0
python,permissions,distutils,setup.py
7,931,034
3
false
0
0
I find that the module is installed without o+rx permissions using disutils I don’t remember right now if distutils copies the files with their rights as is or if it just copies the contents. (in spite of setting umask ahead of running setup.py) I’m not sure how umask and file copying from Python should interact; does umask apply to the system calls or does it need to be explicitly heeded by Python code? For example, is there a way to extract the ending location of the installation from within setup.py? There is one, a bit convoluted. What would you do with that information?
1
1
0
I am configuring a distutils-based setup.py for a python module that is to be installed on a heterogeneous set of resources. Due to the heterogeneity, the location where the module is installed is not the same on each host however disutils picks the host-specific location. I find that the module is installed without o+rx permissions using disutils (in spite of setting umask ahead of running setup.py). One solution is to manually correct this problem, however I would like an automated means that works on heterogeneous install targets. For example, is there a way to extract the ending location of the installation from within setup.py? Any other suggestions?
setting permissions of python module (python setup install)
0
0
0
1,654
2,755,069
2010-05-02T21:27:00.000
2
0
0
1
python,ajax,google-app-engine,tinymce,text-editor
2,758,807
2
false
1
0
It sounds to me like you want to use the Google Docs editor like a widget within your application. To the best of my knowledge you can't do this.
1
1
0
What is the best way to create a custom document editor in GAE? I'm making a website meant for a School Robotics Club (With support for any other organization - DRY). We currently use Google services for online collaboration, I'm wondering if there is a way to tap into Google Docs and allow users to edit a Google Document without using Google Accounts or the Google Docs [EDIT]interface website[/EDIT]. If that is not possible (I've researched and I don't think it is), what is the best way to make a document editor? I want it completely on the website I'm creating, so I'm assuming just some javascript editor like TinyMCE + Ajax + Datastore. Is their anything that replicates Google Doc's/Microsoft Offices's/OpenOffice.org's feature set as far as fonts, spacing, alignment, justification, etc.?
Google App Engine - Document Editor Creation/Tap Into Google Docs?
0.197375
0
0
655
2,755,403
2010-05-02T23:17:00.000
-4
0
1
0
python,function,recursion
2,755,421
6
false
0
0
This sounds like homework. So this is probably cheating: a+b is the same as a.__add__(b), and a-b is the same as a.__sub__(b). So you can easily add or subtract two numbers without using +/-. No need for any recursion.
1
0
0
I need to write a recursive function that can add two numbers (x, y), assuming y is not negative. I need to do it using two functions which return x-1 and x+1, and I can't use + or - anywhere in the code. I have no idea how to start, any hints?
Using recursion to sum two numbers (python)
-1
0
0
6,761
2,756,311
2010-05-03T05:41:00.000
4
1
0
0
python,api,mailman
3,154,975
3
false
1
0
probably too late, but the list_members LISTNAME command (executed from a shell) will give you all the members of a list. list_admins LISTNAME will give you the owners What do you mean by membership type? list_members does have an option to filter on digest vs non-digest members. I don't think there's a way to get the moderation flag without writing a script for use with withlist
1
2
0
I am trying to migrate a legacy mailing list to a new web forum software and was wondering if mailman has an export option or an API to get all lists, owners, members and membership types.
Does Mailman have an API or an export lists, users and owners option?
0.26052
0
1
2,988
2,757,991
2010-05-03T12:33:00.000
2
0
0
1
python,operating-system
2,758,136
1
false
0
0
The ability to change the FSUID is limited to either root or non-root processes with the CAP_SETFCAP capability. These days it's usually considered bad practice to run a webserver with root permissions so, most likely, you'll need to set the capability on the file server (see man capabilities for details). Please note that doing this could severly affect your overall system's security. I'd recommend considering spawning a small backend process that runs as root and converses with your WSGI app via a local UNIX socket prior to mucking with the security of a high-profile target like Apache.
1
0
0
I'm trying to use setfsuid() with python 2.5.4 and RHEL 5.4. Since it's not included in the os module, I wrapped it in a C module of my own and installed it as a python extension module using distutils. However when I try to use it I don't get the expected result. setfsuid() returns value indicating success (changing from a superuser), but I can't access files to which only the newly set user should have user access (using open()), indicating that fsuid was not truely changed. I tried to verify setfsuid() worked, by running it consecutively twice with the same user input The result was as if nothing had changed, and on every call the returned value was of old user id different from the new one. I also called getpid() from the module, and from the python script, both returned the same id. so this is not the problem. Just in case it's significant, I should note that I'm doing all of this from within an Apache daemon process (WSGI). Anyone can provide an explanation to that? Thank you
setfsuid() and python 2.5.4
0.379949
0
0
454
2,758,868
2010-05-03T14:48:00.000
1
0
1
0
python,ruby,shred
2,761,186
2
false
0
0
Since this is a learning exercise and not a professional attempt to secure data. How about this: 1. Discover the length of the file. 2. Write 0's to the same length of the file. 3. Save the file. 4. Delete the file. Then make another program that tries to recover the file. But yes, if looking to make something professional and not just an exercise, look into kitsune's answer.
1
4
0
In the effort to learn python and/or ruby, I was wondering how a file shredder would be implemented? I would like it to take in a file as an argument and then employ an algorithm to make that file unrecoverable. Would possibly add the support for multiple files or even whole directories later.
Writing a file shredder in python or ruby?
0.099668
0
0
2,151
2,758,921
2010-05-03T14:54:00.000
2
0
1
0
python,regex
2,759,044
7
false
0
0
I'd rather just call ord on every character in the string, 1 by 1. If ord([char]) >= 128 the character is not an ascii character and should be replaced.
1
7
0
I need to change some characters that are not ASCII to '_'. For example, Tannh‰user -> Tannh_user If I use regular expression with Python, how can I do this? Is there better way to do this not using RE?
Regular expression that finds and replaces non-ascii characters with Python
0.057081
0
0
17,450
2,759,067
2010-05-03T15:17:00.000
4
0
1
0
python,file-io,file-rename
2,759,105
15
false
0
0
It seems that your problem is more in determining the new file name rather than the rename itself (for which you could use the os.rename method). It is not clear from your question what the pattern is that you want to be renaming. There is nothing wrong with string manipulation. A regular expression may be what you need here.
1
412
0
I'm trying to rename some files in a directory using Python. Say I have a file called CHEESE_CHEESE_TYPE.*** and want to remove CHEESE_ so my resulting filename would be CHEESE_TYPE I'm trying to use the os.path.split but it's not working properly. I have also considered using string manipulations, but have not been successful with that either.
Rename multiple files in a directory in Python
0.053283
0
0
623,079
2,759,323
2010-05-03T15:56:00.000
18
0
1
0
python,path
2,759,329
8
false
0
0
glob.glob or os.listdir will do it.
1
237
0
Can’t be hard, but I’m having a mental block.
How can I list the contents of a directory in Python?
1
0
0
237,951
2,759,623
2010-05-03T16:41:00.000
1
0
1
0
python,installation,dependencies,multiple-versions
2,759,708
8
false
0
0
What I usually do is trying to (progressively) keep up with the Python versions as they come along (and once all of the external dependencies have correct versions available). Most of the time the Python code itself can be transferred as-is with only minor needed modifications. My biggest Python project @ work (15.000+ LOC) is now on Python 2.6 a few months (upgrading everything from Python 2.5 did take most of a day due to installing / checking 10+ dependencies...) In general I think this is the best strategy with most of the interdependent components in the free software stack (think the dependencies in the linux software repositories): keep your versions (semi)-current (or at least: progressing at the same pace).
4
10
0
short version: how can I get rid of the multiple-versions-of-python nightmare ? long version: over the years, I've used several versions of python, and what is worse, several extensions to python (e.g. pygame, pylab, wxPython...). Each time it was on a different setup, with different OSes, sometimes different architectures (like my old PowerPC mac). Nowadays I'm using a mac (OSX 10.6 on x86-64) and it's a dependency nightmare each time I want to revive script older than a few months. Python itself already comes in three different flavours in /usr/bin (2.5, 2.6, 3.1), but I had to install 2.4 from macports for pygame, something else (cannot remember what) forced me to install all three others from macports as well, so at the end of the day I'm the happy owner of seven (!) instances of python on my system. But that's not the problem, the problem is, none of them has the right (i.e. same set of) libraries installed, some of them are 32bits, some 64bits, and now I'm pretty much lost. For example right now I'm trying to run a three-year-old script (not written by me) which used to use matplotlib/numpy to draw a real-time plot within a rectangle of a wxwidgets window. But I'm failing miserably: py26-wxpython from macports won't install, stock python has wxwidgets included but also has some conflict between 32 bits and 64 bits, and it doesn't have numpy... what a mess ! Obviously, I'm doing things the wrong way. How do you usally cope with all that chaos ?
How to maintain long-lived python projects w.r.t. dependencies and python versions?
0.024995
0
0
737
2,759,623
2010-05-03T16:41:00.000
4
0
1
0
python,installation,dependencies,multiple-versions
2,759,813
8
true
0
0
Some tips: on Mac OS X, use only the python installation in /Library/Frameworks/Python.framework. whenever you use numpy/scipy/matplotlib, install the enthought python distribution use virtualenv and virtualenvwrapper to keep those "system" installations pristine; ideally use one virtual environment per project, so each project's dependencies are fulfilled. And, yes, that means potentially a lot of code will be replicated in the various virtual envs. That seems like a bigger mess indeed, but at least things work that way. Basically, if one of the projects works in a virtualenv, it will keep working no matter what upgrades you perform, since you never change the "system" installs.
4
10
0
short version: how can I get rid of the multiple-versions-of-python nightmare ? long version: over the years, I've used several versions of python, and what is worse, several extensions to python (e.g. pygame, pylab, wxPython...). Each time it was on a different setup, with different OSes, sometimes different architectures (like my old PowerPC mac). Nowadays I'm using a mac (OSX 10.6 on x86-64) and it's a dependency nightmare each time I want to revive script older than a few months. Python itself already comes in three different flavours in /usr/bin (2.5, 2.6, 3.1), but I had to install 2.4 from macports for pygame, something else (cannot remember what) forced me to install all three others from macports as well, so at the end of the day I'm the happy owner of seven (!) instances of python on my system. But that's not the problem, the problem is, none of them has the right (i.e. same set of) libraries installed, some of them are 32bits, some 64bits, and now I'm pretty much lost. For example right now I'm trying to run a three-year-old script (not written by me) which used to use matplotlib/numpy to draw a real-time plot within a rectangle of a wxwidgets window. But I'm failing miserably: py26-wxpython from macports won't install, stock python has wxwidgets included but also has some conflict between 32 bits and 64 bits, and it doesn't have numpy... what a mess ! Obviously, I'm doing things the wrong way. How do you usally cope with all that chaos ?
How to maintain long-lived python projects w.r.t. dependencies and python versions?
1.2
0
0
737
2,759,623
2010-05-03T16:41:00.000
1
0
1
0
python,installation,dependencies,multiple-versions
2,844,226
8
false
0
0
install the python versions you need, better if from sources when you write a script, include the full python version into it (such as #!/usr/local/bin/python2.6) I can't see what could go wrong. If something does, it's probably macports fault anyway, not yours (one of the reasons I don't use macports anymore). I know I'm probably missing something and this will get downvoted, but please leave at least a little comment in that case, thanks :)
4
10
0
short version: how can I get rid of the multiple-versions-of-python nightmare ? long version: over the years, I've used several versions of python, and what is worse, several extensions to python (e.g. pygame, pylab, wxPython...). Each time it was on a different setup, with different OSes, sometimes different architectures (like my old PowerPC mac). Nowadays I'm using a mac (OSX 10.6 on x86-64) and it's a dependency nightmare each time I want to revive script older than a few months. Python itself already comes in three different flavours in /usr/bin (2.5, 2.6, 3.1), but I had to install 2.4 from macports for pygame, something else (cannot remember what) forced me to install all three others from macports as well, so at the end of the day I'm the happy owner of seven (!) instances of python on my system. But that's not the problem, the problem is, none of them has the right (i.e. same set of) libraries installed, some of them are 32bits, some 64bits, and now I'm pretty much lost. For example right now I'm trying to run a three-year-old script (not written by me) which used to use matplotlib/numpy to draw a real-time plot within a rectangle of a wxwidgets window. But I'm failing miserably: py26-wxpython from macports won't install, stock python has wxwidgets included but also has some conflict between 32 bits and 64 bits, and it doesn't have numpy... what a mess ! Obviously, I'm doing things the wrong way. How do you usally cope with all that chaos ?
How to maintain long-lived python projects w.r.t. dependencies and python versions?
0.024995
0
0
737
2,759,623
2010-05-03T16:41:00.000
0
0
1
0
python,installation,dependencies,multiple-versions
2,853,892
8
false
0
0
At least under Linux, multiple pythons can co-exist fairly happily. I use Python 2.6 on a CentOS system that needs Python 2.4 to be the default for various system things. I simply compiled and installed python 2.6 into a separate directory tree (and added the appropriate bin directory to my path) which was fairly painless. It's then invoked by typing "python2.6". Once you have separate pythons up and running, installing libraries for a specific version is straightforward. If you invoke the setup.py script with the python you want, it will be installed in directories appropriate to that python, and scripts will be installed in the same directory as the python executable itself and will automagically use the correct python when invoked. I also try to avoid using too many libraries. When I only need one or two functions from a library (eg scipy), I'll often see if I can just copy them to my own project.
4
10
0
short version: how can I get rid of the multiple-versions-of-python nightmare ? long version: over the years, I've used several versions of python, and what is worse, several extensions to python (e.g. pygame, pylab, wxPython...). Each time it was on a different setup, with different OSes, sometimes different architectures (like my old PowerPC mac). Nowadays I'm using a mac (OSX 10.6 on x86-64) and it's a dependency nightmare each time I want to revive script older than a few months. Python itself already comes in three different flavours in /usr/bin (2.5, 2.6, 3.1), but I had to install 2.4 from macports for pygame, something else (cannot remember what) forced me to install all three others from macports as well, so at the end of the day I'm the happy owner of seven (!) instances of python on my system. But that's not the problem, the problem is, none of them has the right (i.e. same set of) libraries installed, some of them are 32bits, some 64bits, and now I'm pretty much lost. For example right now I'm trying to run a three-year-old script (not written by me) which used to use matplotlib/numpy to draw a real-time plot within a rectangle of a wxwidgets window. But I'm failing miserably: py26-wxpython from macports won't install, stock python has wxwidgets included but also has some conflict between 32 bits and 64 bits, and it doesn't have numpy... what a mess ! Obviously, I'm doing things the wrong way. How do you usally cope with all that chaos ?
How to maintain long-lived python projects w.r.t. dependencies and python versions?
0
0
0
737
2,759,738
2010-05-03T17:00:00.000
0
1
0
0
c++,python,graphics,video,video-processing
2,760,860
1
true
0
1
I'm not sure I understand the question correctly but a video file is a sequence of pictures that you can extract (for instance with the opencv library C++ interface) and then you can use it wherever you want. You can play the video on the sides of an opengl 3D cube (available in all opengl tutorials) and other 3D elements around it. Of course you can also displays it in a conventional 2D interface and draw stuff on top of it, but for this you need a graphical ui. Is it what you thought or am I completely lost?
1
0
0
Imagine I have a video playing.. Can I have some sort of motion graphics being played 'over' that video.. Like say the moving graphics is on an upper layer than the video, which would be the lower layer.. I am comfortable in a C++ and Python, so a solution that uses these two will be highly appreciated.. Thank you in advance, Rishi..
Navigation graphics overlayed over video
1.2
0
0
169
2,760,652
2010-05-03T19:29:00.000
16
0
1
1
python,subprocess
12,956,839
9
false
0
0
If you delete the subprocess object, using del to force garbage collection, that will cause the subprocess object to be deleted and then the defunct processes will go away without terminating your interpreter. You can try this out in the python command line interface first.
4
53
0
When I kick off a python script from within another python script using the subprocess module, a zombie process is created when the subprocess "completes". I am unable to kill this subprocess unless I kill my parent python process. Is there a way to kill the subprocess without killing the parent? I know I can do this by using wait(), but I need to run my script with no_wait().
how to kill (or avoid) zombie processes with subprocess module
1
0
0
62,258
2,760,652
2010-05-03T19:29:00.000
5
0
1
1
python,subprocess
6,236,440
9
false
0
0
The python runtime takes responsibility for getting rid of zombie process once their process objects have been garbage collected. If you see the zombie lying around it means you have kept a process object and not called wait, poll or terminate on it.
4
53
0
When I kick off a python script from within another python script using the subprocess module, a zombie process is created when the subprocess "completes". I am unable to kill this subprocess unless I kill my parent python process. Is there a way to kill the subprocess without killing the parent? I know I can do this by using wait(), but I need to run my script with no_wait().
how to kill (or avoid) zombie processes with subprocess module
0.110656
0
0
62,258
2,760,652
2010-05-03T19:29:00.000
0
0
1
1
python,subprocess
40,458,489
9
false
0
0
Recently, I came across this zombie problem due to my python script. The actual problem was mainly due to killing of the subprocess and the parent process doesn't know that the child is dead. So what I did was, just adding popen.communicate() after the kill signal of child process so that the parent process comes to know that the child is dead, then the kernel updates the pid of the childprocess since the child is no more and so there is no zombies formed now. PS:poll is also an option here since it checks and conveys about the child status to the parent. Often in subprocess it is better if u use check_output or call if u need not communicate with the stdout and stdin.
4
53
0
When I kick off a python script from within another python script using the subprocess module, a zombie process is created when the subprocess "completes". I am unable to kill this subprocess unless I kill my parent python process. Is there a way to kill the subprocess without killing the parent? I know I can do this by using wait(), but I need to run my script with no_wait().
how to kill (or avoid) zombie processes with subprocess module
0
0
0
62,258
2,760,652
2010-05-03T19:29:00.000
1
0
1
1
python,subprocess
64,438,478
9
false
0
0
Like this: s = Popen(args) s.terminate() time.sleep(0.5) s.poll() it works zombie processes will disappear
4
53
0
When I kick off a python script from within another python script using the subprocess module, a zombie process is created when the subprocess "completes". I am unable to kill this subprocess unless I kill my parent python process. Is there a way to kill the subprocess without killing the parent? I know I can do this by using wait(), but I need to run my script with no_wait().
how to kill (or avoid) zombie processes with subprocess module
0.022219
0
0
62,258
2,761,145
2010-05-03T20:57:00.000
0
1
1
0
python
2,761,222
3
false
0
0
It depends on your definition of "method". In some sense, no, classes aren't necessary for creating methods in Python, because there are no methods anyway in Python. There are only procedures (which, for some strange reason, are called functions in Python). You can create a procedure anywhere you like. A method is just syntactic sugar for a procedure assigned to an attribute. In another sense, yes, classes are necessary for creating methods. It follows pretty much from the definition of what a method is in Python: a procedure stuck into a class's __dict__. (Note, however, that this means that you do not have to be inside a class definition to create method, you can create a procedure anywhere and any way you like and stick it into the class afterwards.) [Note: I have simplified a bit when it comes to exactly what a method is, how they are synthesized, how they are represented and how you can create your own.]
1
3
0
Are classes necessary for creating methods (defs) in Python?
Are classes necessary for creating methods (defs) in Python?
0
0
0
380