2,209,294 questions
59
votes
10
answers
33k
views
How to write a download progress indicator in Python?
I am writing a little application to download files over http (as, for example, described here).
I also want to include a little download progress indicator showing the percentage of the download ...
12
votes
1
answer
952
views
How do you create a weak reference to an object in Python?
How do you create a weak reference to an object in Python?
603
votes
26
answers
637k
views
How to get the path and name of the Python file that is currently executing?
I have scripts calling other script files but I need to get the filepath of the file that is currently running within the process.
For example, let's say I have three files. Using execfile:
script_1....
37
votes
10
answers
48k
views
Open source alternative to MATLAB's fmincon function? [closed]
Is there an open-source alternative to MATLAB's fmincon function for constrained linear optimization? I'm rewriting a MATLAB program to use Python / NumPy / SciPy and this is the only function I haven'...
14
votes
7
answers
8k
views
Can parallel traversals be done in MATLAB just as in Python?
Using the zip function, Python allows for loops to traverse multiple sequences in parallel.
for (x,y) in zip(List1, List2):
Does MATLAB have an equivalent syntax? If not, what is the best way to ...
21
votes
3
answers
9k
views
How do I turn a python program into an .egg file?
How do I turn a python program into an .egg file?
74
votes
7
answers
146k
views
Calling python from a c++ program for distribution
I would like to call python script files from my c++ program.
I am not sure that the people I will distribute to will have python installed.
8
votes
2
answers
4k
views
How do I implement a pre-commit hook script in SVN that calls dos2unix to validate checked-in file
I was wondering if anyone here had some experience writing this type of script and if they could give me some pointers.
I would like to modify this script to validate that the check-in file does not ...
5
votes
4
answers
2k
views
Embedding a remote Python shell in an application
You can embed the IPython shell inside of your application so that it launches the shell in the foreground. Is there a way to embed a telnet server in a python app so that you can telnet to a certain ...
28
votes
6
answers
11k
views
What are the advantages of packaging your python library/application as an .egg file?
I've read some about .egg files and I've noticed them in my lib directory but what are the advantages/disadvantages of using then as a developer?
550
votes
13
answers
239k
views
Generator expressions vs. list comprehensions
When should you use generator expressions and when should you use list comprehensions in Python?
# Generator expression
(x*2 for x in range(256))
# List comprehension
[x*2 for x in range(256)]
32
votes
3
answers
18k
views
How do you set up a Python WSGI server under IIS?
I work in a Windows environment and would prefer to deploy code to IIS. At the same time I would like to code in Python.
Having read that IIS can run fastCGI application, I went to the IIS site where ...
15
votes
6
answers
5k
views
Which Version of Python to Use for Maximum Compatibility
If I was going to start an open source project using Python what version should I use to ensure that the vast majority of users can use it on their system?
I'm the kind of person who quickly jumps to ...
7
votes
2
answers
2k
views
How to know whether a window with a given title is already open in Tk?
I’ve writen a little python script that just pops up a message box containing the text passed on the command line. I want to pop it up only when the window —resulting from a previous call— is not open....
9
votes
4
answers
4k
views
Wacom tablet Python interface
If possible I want to catch pressure sensitive input from a Wacom tablet in Python. Are there any Python libraries available that can do this?
19
votes
3
answers
4k
views
Where can I find the time and space complexity of the built-in sequence types in Python
I've been unable to find a source for this information, short of looking through the Python source code myself to determine how the objects work. Does anyone know where I could find this online?
5
votes
1
answer
214
views
Can the HTTP version or headers affect the visual appearance of a web page?
I know, I would have thought the answer was obviously "no" as well, but I am experiencing a strange situation where when I view my site from our staging server it appears slightly larger than when I ...
725
votes
15
answers
943k
views
How would you make a comma-separated string from a list of strings?
What would be your preferred way to concatenate strings from a sequence such that between every two consecutive pairs a comma is added. That is, how do you map, for instance, ['a', 'b', 'c'] to 'a,b,c'...
44
votes
6
answers
8k
views
Project design / FS layout for large django projects [closed]
What is the best way to layout a large django project? The tutorials provide simple instructions for setting up apps, models, and views, but there is less information about how apps and projects ...
12
votes
11
answers
16k
views
invisible watermarks in images [closed]
How do you insert invisible watermarks in images for copyright purposes? I'm looking for a python library.
What algorithm do you use? What about performance and efficiency?
18
votes
12
answers
13k
views
Modulus operation with negatives values - weird thing? [duplicate]
Can you please tell me how much is (-2) % 5?
According to my Python interpreter is 3, but do you have a wise explanation for this?
I've read that in some languages the result can be machine-dependent,...
283
votes
19
answers
323k
views
How to find the mime type of a file in python?
Let's say you want to save a bunch of files somewhere, for instance in BLOBs. Let's say you want to dish these files out via a web page and have the client automatically open the correct application/...
97
votes
14
answers
176k
views
Can I write native iPhone apps using Python? [closed]
Using PyObjC, you can use Python to write Cocoa applications for OS X. Can I write native iPhone apps using Python and if so, how?
5
votes
1
answer
712
views
How can I get a commit message from a bzr post-commit hook?
I'm trying to write a bzr post-commit hook for my private bugtracker, but I'm stuck at the function signature of
post_commit(local, master, old_revno, old_revid, new_revno, mew_revid)
How can I ...
78
votes
3
answers
51k
views
Python re.sub with a flag does not replace all occurrences
The Python docs say:
re.MULTILINE: When specified, the pattern character '^' matches at the beginning of the string and at the beginning of each line (immediately following each newline)... By ...