Skip to main content
Filter by
Sorted by
Tagged with
25 votes
13 answers
82k views

Is there a reasonable way to extract plain text from a Word file that doesn't depend on COM automation? (This is a a feature for a web app deployed on a non-Windows platform - that's non-negotiable ...
Kevin's user avatar
  • 1,293
59 votes
12 answers
56k views

I am learning Python for a class now, and we just covered tuples as one of the data types. I read the Wikipedia page on it, but, I could not figure out where such a data type would be useful in ...
Sam McAfee's user avatar
  • 10.2k
13 votes
9 answers
10k views

I have a method in my Python code that returns a tuple - a row from a SQL query. Let's say it has three fields: (jobId, label, username) For ease of passing it around between functions, I've been ...
andygeers's user avatar
  • 7,076
35 votes
8 answers
33k views

I am working on a small intranet site for a small company, where user should be able to post. I have imagined a very simple authentication mechanism where people just enter their email address, and ...
Staale's user avatar
  • 28.1k
2 votes
1 answer
5k views

In a try/except block, how do I extract the Oracle error number?
Mark Harrison's user avatar
7 votes
2 answers
3k views

What is the easiest way to create and verify PGP/GPG signatures from within a Python application? I can call pgp or gpg using subprocess and parse the output, but I was looking for a way that didn't ...
dF.'s user avatar
  • 76.1k
27 votes
2 answers
15k views

I'm reading some MPEG Transport Stream protocol over UDP and it has some funky bitfields in it (length 13 for example). I'm using the "struct" library to do the broad unpacking, but is there a simple ...
ZebZiggle's user avatar
  • 688
386 votes
13 answers
662k views

I want to loop over the contents of a text file and do a search and replace on some lines and write the result back to the file. I could first load the whole file in memory and then write it back, but ...
pkit's user avatar
  • 8,369
183 votes
18 answers
141k views

How can I use the nifty JavaScript date and time widgets that the default admin uses with my custom view? I have looked through the Django forms documentation, and it briefly mentions django.contrib....
Josh Hunt's user avatar
  • 14.5k
3 votes
2 answers
2k views

Given an Oracle table created using the following: CREATE TABLE Log(WhenAdded TIMESTAMP(6) WITH TIME ZONE); Using the Python ODBC module from its Win32 extensions (from the win32all package), I tried ...
Jason Etheridge's user avatar
4 votes
3 answers
732 views

The primary class in the subprocess module is name Popen, and represents a subprocess. Popen sounds like someone was trying to force the name to follow some function naming format, rather than chosing ...
user1114's user avatar
24 votes
6 answers
32k views

I've got a bunch of FoxPro (VFP9) DBF files on my Ubuntu system, is there a library to open these in Python? I only need to read them, and would preferably have access to the memo fields too. Update:...
Tom's user avatar
  • 44.9k
1 vote
6 answers
562 views

Below I have a very simple example of what I'm trying to do. I want to be able to use HTMLDecorator with any other class. Ignore the fact it's called decorator, it's just a name. import cgi class ...
Harley Holcombe's user avatar
65 votes
8 answers
47k views

Can people point me to resources on lexing, parsing and tokenising with Python? I'm doing a little hacking on an open source project (hotwire) and wanted to do a few changes to the code that lexes, ...
Hamish Downer's user avatar
3488 votes
28 answers
1.5m views

What do *args and **kwargs mean in these function definitions? def foo(x, y, *args): pass def bar(x, y, **kwargs): pass See What do ** (double star/asterisk) and * (star/asterisk) mean in a ...
Todd's user avatar
  • 36.2k
13 votes
4 answers
12k views

I have been sold on mod_wsgi and apache rather than mod_python. I have all the parts installed (django, apache, mod_wsgi) but have run into a problem deploying. I am on osx 10.5 with apache 2.2 and ...
Doug Miller's user avatar
  • 1,346
14 votes
1 answer
18k views

I'm trying to use svnmerge.py to merge some files. Under the hood it uses python, and when I use it I get an error - "The system cannot find the file specified". Colleagues at work are ...
Hobo's user avatar
  • 7,621
711 votes
28 answers
1.0m views

Is there a way to conveniently define a C-like structure in Python? I'm tired of writing stuff like: class MyStruct(): def __init__(self, field1, field2, field3): self.field1 = field1 ...
wesc's user avatar
  • 7,131
147 votes
10 answers
125k views

When using os.system() it's often necessary to escape filenames and other arguments passed as parameters to commands. How can I do this? Preferably something that would work on multiple operating ...
Tom's user avatar
  • 44.9k
29 votes
13 answers
30k views

Right now I'm developing mostly in C/C++, but I wrote some small utilities in Python to automatize some tasks and I really love it as language (especially the productivity). Except for the ...
martjno's user avatar
  • 4,779
14 votes
1 answer
878 views

It seems like if you want to get the keys of a mapping, you ask for them; otherwise, give me the whole mapping (constituted by a set of key-value pairs). Is there a historical reason for this?
cdleary's user avatar
  • 71.8k
10 votes
3 answers
2k views

Is there anything similar to rails' scaffolding for pylons? I've been poking around google, but only found this thing called dbsprockets, which is fine, although probably way too much for my needs. ...
Bartosz Radaczyński's user avatar
11 votes
4 answers
9k views

In another question I posted yesterday, I got very good advice on how a Python script could be run as a service in Windows. What I'm left wondering is: How is Windows aware of the services that can be ...
Hanno Fietz's user avatar
  • 31.5k
6 votes
3 answers
1k views

In the transition to newforms admin I'm having difficulty figuring out how specify core=False for ImageFields. I get the following error: TypeError: __init__() got an unexpected keyword argument '...
cdleary's user avatar
  • 71.8k
28 votes
6 answers
13k views

A reliable coder friend told me that Python's current multi-threading implementation is seriously buggy - enough to avoid using altogether. What can said about this rumor?
Tyler's user avatar
  • 28.9k