Detecting arguments of a function - possible?
Kent Johnson
kent at kentsjohnson.com
Fri Mar 17 09:10:22 EST 2006
Chance Ginger wrote:
> I am trying to write a tool to examine a function (I'd like it
> to work with pyc files only). So here are a few questions I
> have; any pointers would be very welcome.
>
> Can I determine the number of arguments required of a function?
See inspect.getargspec()
> Is there a way to detect is the function will throw an exception
> (I don't care under what conditions just that it is possible)?
If you mean something like Java's throws declaration, no, Python doesn't
have that. Any function can raise an exception. IIUC even something as
simple as
def foo(): pass
can raise KeyboardInterrupt
Kent
More information about the Python-list
mailing list