Skip to main content
Filter by
Sorted by
Tagged with
31 votes
2 answers
11k views

I need to validate an XML string (and not a file) against a DTD description file. How can that be done in python?
fulmicoton's user avatar
  • 16.1k
31 votes
4 answers
18k views

I have a script that parses the filenames of TV episodes (show.name.s01e02.avi for example), grabs the episode name (from the www.thetvdb.com API) and automatically renames them into something nicer (...
dbr's user avatar
  • 171k
78 votes
7 answers
90k views

I'd like to have a python program alert me when it has completed its task by making a beep noise. Currently, I use import os and then use a command line speech program to say "Process complete&...
stalepretzel's user avatar
17 votes
5 answers
2k views

I am trying to implement string unescaping with Python regex and backreferences, and it doesn't seem to want to work very well. I'm sure it's something I'm doing wrong but I can't figure out what... &...
eplawless's user avatar
  • 4,329
12 votes
6 answers
683 views

I love list comprehensions in Python, because they concisely represent a transformation of a list. However, in other languages, I frequently find myself writing something along the lines of: foreach ...
pbh101's user avatar
  • 10.4k
10 votes
3 answers
3k views

Is there a way, when I parse an XML document using lxml, to validate that document against its DTD using an external catalog file? I need to be able to work the fixed attributes defined in a ...
James Sulak's user avatar
  • 32.6k
15 votes
7 answers
5k views

I'm trying to decode the result of the Python os.wait() function. This returns, according to the Python docs: a tuple containing its pid and exit status indication: a 16-bit number, whose low byte ...
Lorin Hochstein's user avatar
266 votes
11 answers
401k views

What are the libraries that support XPath? Is there a full implementation? How is the library used? Where is its website?
user avatar
17 votes
5 answers
2k views

Basically, I've written an API to www.thetvdb.com in Python. The current code can be found here. It grabs data from the API as requested, and has to store the data somehow, and make it available by ...
dbr's user avatar
  • 171k
182 votes
16 answers
142k views

When I try to print a string in a Windows console, sometimes I get an error that says UnicodeEncodeError: 'charmap' codec can't encode character ..... I assume this is because the Windows console ...
James Sulak's user avatar
  • 32.6k
15 votes
4 answers
3k views

A researcher has created a small simulation in MATLAB and we want to make it accessible to others. My plan is to take the simulation, clean up a few things and turn it into a set of functions. Then I ...
Marcel Levy's user avatar
  • 3,437
14 votes
8 answers
2k views

When asked to create system XYZ and you ask to do it in Python over PHP or Ruby, what are the main features you can mention when they require you to explain it?
Teifion's user avatar
  • 112k
324 votes
86 answers
151k views

Original Question I am currently engaged in teaching my brother to program. He is a total beginner, but very smart. (And he actually wants to learn). I've noticed that some of our sessions have ...
315 votes
14 answers
245k views

Python works on multiple platforms and can be used for desktop and web applications, thus I conclude that there is some way to compile it into an executable for Mac, Windows and Linux. The problem ...
Teifion's user avatar
  • 112k
60 votes
18 answers
20k views

In many places, (1,2,3) (a tuple) and [1,2,3] (a list) can be used interchangeably. When should I use one or the other, and why?
Mark Harrison's user avatar
27 votes
4 answers
15k views

I've got a menu in Python. That part was easy. I'm using raw_input() to get the selection from the user. The problem is that raw_input (and input) require the user to press Enter after they make a ...
Grant's user avatar
  • 12.1k
415 votes
8 answers
362k views

How do you express an integer as a binary number with Python literals? I was easily able to find the answer for hex: >>> 0x12AF 4783 >>> 0x100 256 and octal: >>> 01267 ...
Justin Standard's user avatar
867 votes
19 answers
412k views

How do I add a method to an existing object (i.e., not in the class definition) in Python? I understand that it's not generally considered good practice to do so, except in some cases.
akdom's user avatar
  • 33.5k
45 votes
6 answers
5k views

I can get Python to work with Postgresql but I cannot get it to work with MySQL. The main problem is that on the shared hosting account I have I do not have the ability to install things such as ...
Teifion's user avatar
  • 112k
58 votes
8 answers
16k views

I don't remember whether I was dreaming or not but I seem to recall there being a function which allowed something like, foo in iter_attr(array of python objects, attribute name) I've looked over ...
Brendan's user avatar
  • 19.5k
68 votes
7 answers
10k views

I am starting to work on a hobby project with a Python codebase and I would like to set up some form of continuous integration (i.e. running a battery of test-cases each time a check-in is made and ...
Matt's user avatar
  • 5,931
48 votes
6 answers
6k views

I am using the Photoshop's javascript API to find the fonts in a given PSD. Given a font name returned by the API, I want to find the actual physical font file that font name corresponds to on the ...
Gareth Simpson's user avatar