Is there any way in Python to determine what exceptions a (built-in) function might raise? For example, the documentation (http://docs.python.org/lib/built-in-funcs.html) for the built-in int(s) says nothing about the fact that it might raise a ValueError if s is not a validly formatted int.
This is a duplicate of http://stackoverflow...
If I have two dates (ex. '8/18/2008' and '9/26/2008') what is the best way to get the difference measured in days?
...
This isn't as malicious as it sounds, I want to get the current size of their windows, not look at what is in them. The purpose is to figure out that if every other window is fullscreen then I should start up like that too. Or if all the other processes are only 800x600 despite there being a huge resolution then that is probably what t...
Hello,
I'm using the mechanize module to execute some web queries from Python. I want my program to be error-resilient and handle all kinds of errors (wrong URLs, 403/404 responsese) gracefully. However, I can't find in mechanize's documentation the errors / exceptions it throws for various errors.
I just call it with:
self.browser...
I've been working on a very simple crud generator for pylons. I came up with something that inspects
SomeClass._sa_class_manager.mapper.c
Is it ok to inspect this (or to call methods begining with underscore)? I always kind of assumed this is legal though frowned upon as it relies heavily on the internal structure of a class/object. ...
Here's the problem:
split=re.compile('\W*')
works fine when dealing with regular words, but there are occasions where I need the expression to include words like käyttäjauml;.
What should I add to the regex to include the & and ; characters?
...
I have a statusItem application written in PyObjC. The statusItem has a menuItem which is supposed to launch a new window when it is clicked:
# Create statusItem
statusItem = NSStatusBar.systemStatusBar().statusItemWithLength_(NSVariableStatusItemLength)
statusItem.setHighlightMode_(TRUE)
statusItem.setEnabled_(TRUE)
statusItem.retain()...
Someone asked this for C++ blogs and got a lot of great answers but I am much more interested in Python blogs. So, what Python blogs do you subscribe to?
One URL per answer please?
...
What is the best way to check if a given object is of a given type. How about checking if the object inherits from a given type.
Let's say I have an object o. How do I check if it's an str?
...
I have a small web server application I've written in Python that goes and gets some data from a database system and returns it to the user as XML. That part works fine - I can run the Python web server application from the command line and I can have clients connect to it and get data back. At the moment, to run the web server I have to...
When I call
help(Mod.Cls.f)
(Mod is a C extension module), I get the output
Help on method_descriptor:
f(...)
doc_string
What do I need to do so that the help output is of the form
Help on method f in module Mod:
f(x, y, z)
doc_string
like it is for random.Random.shuffle, for example?
My PyMethodDef entry is currently:
...
Is there a tool out there that can automatically convert Python to Java?
Can Jython do this?
...
How do I iterate over a timespan after days, hours, weeks or months?
Something like:
for date in foo(from_date, to_date, delta=HOURS):
print date
Where foo is a function, returning an iterator. I've been looking at the calendar module, but that only works for one specific year or month, not between dates.
...
I'm trying to redirect/forward a Pylons request. The problem with using redirect_to is that form data gets dropped. I need to keep the POST form data intact as well as all request headers.
Is there a simple way to do this?
...
I need to develop a small-medium sized desktop GUI application, preferably with Python as a language of choice because of time constraints.
What GUI library choices do I have which allow me to redistribute my application standalone, assuming that the users don't have a working Python installation and obviously don't have the GUI librari...
Can I run the python interpreter without generating the compiled .pyc files?
...
Timsort is an adaptive, stable,
natural mergesort. It has supernatural
performance on many kinds of partially
ordered arrays (less than lg(N!)
comparisons needed, and as few as
N-1), yet as fast as Python's previous
highly tuned samplesort hybrid on
random arrays.
Have you seen timsort used outside of CPython? Does it ...
Is there a Python module for converting wiki markup to other languages (e.g. HTML)?
A similar question was asked here, What's the easiest way to convert wiki markup to html, but no Python modules are mentioned.
Just curious. :) Cheers.
...
A few weeks ago I've run into a site that had tutorials for many languages including Perl, Ruby, Python. The concept was that it basically showed you the code itself of the given language and taught you like that, so the whole tutorial was a great amount of code and some comments in it. The only problem is that I forgot to bookmark it an...
I'm trying to develop an app using turbogears and sqlalchemy.
There is already an existing app using kinterbasdb directly under mod_wsgi on the same server.
When both apps are used, neither seems to recognize that kinterbasdb is already initialized
Is there something non-obvious I am missing about using sqlalchemy and kinterbasdb in sepa...