Skip to main content
Filter by
Sorted by
Tagged with
1 vote
6 answers
2k views

In Python is there any way to make a class, then make a second version of that class with identical dat,a but which can be changed, then reverted to be the same as the data in the original class? So ...
leachrode's user avatar
  • 312
-1 votes
3 answers
1k views

I recently discovered the notify extension in Mercurial which allows me quickly send out emails whenever I push changes, but I'm pretty sure I'm still missing out on a lot of functionality which could ...
53 votes
16 answers
118k views

What is the easiest way to compare strings in Python, ignoring case? Of course one can do (str1.lower() <= str2.lower()), etc., but this created two additional temporary strings (with the obvious ...
Paul Oyster's user avatar
  • 2,267
5 votes
2 answers
5k views

So I've done the trivial "warmup" apps with GAE. Now I'd like to build something with a more complex directory structure. Something along the lines of: siteroot/ models/ controllers/ ...
Rob Collins's user avatar
95 votes
9 answers
78k views

In python, you can have a function return multiple values. Here's a contrived example: def divide(x, y): quotient = x/y remainder = x % y return quotient, remainder (q, r) = divide(22,...
readonly's user avatar
  • 358k
577 votes
18 answers
147k views

If you're writing a library, or an app, where do the unit test files go? It's nice to separate the test files from the main app code, but it's awkward to put them into a "tests" subdirectory inside ...
readonly's user avatar
  • 358k
107 votes
9 answers
61k views

How do I select one or more random rows from a table using SQLAlchemy?
cnu's user avatar
  • 37.4k
22 votes
3 answers
40k views

I'm writing a small web server in Python, using BaseHTTPServer and a custom subclass of BaseHTTPServer.BaseHTTPRequestHandler. Is it possible to make this listen on more than one port? What I'm doing ...
JW.'s user avatar
  • 51.9k
-1 votes
2 answers
2k views

If all of my __init__.py files are empty, do I have to store them into version control, or is there a way to make distutils create empty __init__.py files during installation?
jelovirt's user avatar
  • 5,902
12 votes
8 answers
23k views

Been scouring the net for something like firewatir but for python. I'm trying to automate firefox on linux. Any suggestions?
RyanBrady's user avatar
  • 7,003
3 votes
6 answers
19k views

I am writing a program to simulate the actual polling data companies like Gallup or Rasmussen publish daily: www.gallup.com and www.rassmussenreports.com I'm using a brute force method, where the ...
andy's user avatar
  • 51
107 votes
5 answers
189k views

I like Doxygen to create documentation of C or PHP code. I have an upcoming Python project and I think I remember that Python doesn't have /* .. */ comments, and also has its own self-documentation ...
Hanno Fietz's user avatar
  • 31.5k
17 votes
2 answers
8k views

I can't tell from the Python documentation whether the re.compile(x) function may throw an exception (assuming you pass in a string). I imagine there is something that could be considered an invalid ...
postfuturist's user avatar
  • 22.7k
147 votes
21 answers
299k views

The documentation for the round() function states that you pass it a number, and the positions past the decimal to round. Thus it should do this: n = 5.59 round(n, 1) # 5.6 But, in actuality, good ...
swilliams's user avatar
  • 49.1k
717 votes
19 answers
895k views

According to the documentation, they're pretty much interchangeable. Is there a stylistic reason to use one over the other?
readonly's user avatar
  • 358k
6 votes
3 answers
2k views

I use Emacs primarily for coding Python but sometimes I use IDLE. Is there a way to change the key bindings easily in IDLE to match Emacs?
Ray's user avatar
  • 194k
113 votes
15 answers
52k views

I'm building a Django project that needs search functionality, and until there's a django.contrib.search, I have to choose a search app. So, which is the best? By "best" I mean... easy to install / ...
Justin Voss's user avatar
  • 6,374
14 votes
11 answers
12k views

I am trying to implement AJAX in my Google App Engine application, and so I am looking for a good AJAX framework that will help me. Anyone has any idea? I am thinking about Google Web Toolkit, how ...
Graviton's user avatar
  • 83.2k
16 votes
6 answers
1k views

Having tries to target two of these environments at the same time I can safely say the if you have to use a database etc. you end up having to write unique code for that environment. Have you got a ...
minty's user avatar
  • 22.4k
267 votes
12 answers
252k views

I'm evaluating and looking at using CherryPy for a project that's basically a JavaScript front-end from the client-side (browser) that talks to a Python web service on the back-end. So, I really need ...
eLuke's user avatar
  • 2,723
6 votes
3 answers
2k views

I want to scrape some information off a football (soccer) web page using simple python regexp's. The problem is that players such as the first chap, ÄÄRITALO, comes out as &#196;&#196;RITALO! ...
Nick Fortescue's user avatar
3 votes
2 answers
604 views

I have a file that I want to include in Python but the included file is fairly long and it'd be much neater to be able to split them into several files but then I have to use several include ...
Teifion's user avatar
  • 112k
77 votes
12 answers
50k views

I need a way to determine the space remaining on a disk volume using python on linux, Windows and OS X. I'm currently parsing the output of the various system calls (df, dir) to accomplish this - is ...
user avatar
1078 votes
12 answers
1.6m views

Given a path such as "mydir/myfile.txt", how do I find the file's absolute path in Python? E.g. on Windows, I might end up with: "C:/example/cwd/mydir/myfile.txt"
izb's user avatar
  • 52.2k
13 votes
3 answers
11k views

Say I have the following methods: def methodA(arg, **kwargs): pass def methodB(arg, *args, **kwargs): pass In methodA I wish to call methodB, passing on the kwargs. However, it seems that if ...
Staale's user avatar
  • 28.1k