[Tutor] Introspect function or class' required arguments

Luis N globophobe at gmail.com
Fri Dec 14 06:06:31 CET 2007

On Dec 14, 2007 12:08 PM, Kent Johnson <kent37 at tds.net> wrote:
> Luis N wrote:
> > Is there a way to introspect a function or class' required arguments,
> > particularly keyword arguments?
> See inspect.getargspec() and formatargspec().
> Look at the source if you want details of where the info is stored.

Thanks that's exactly what I was looking for :-)

> > I can easily use a dictionary since it is my own function that I wish
> > to introspect. I haven't tested the below code yet, but e.g.
> I don't understand what you are trying to do here.

The code I posted before is to be part of a dispatcher for a django
application. Objects are routed to 'add', 'edit', or 'delete' methods.
Data for some of the fields/attributes of my django models objects
needs to be preprocessed.

However, as the add/edit/delete methods are used for multiple objects
I need to determine dynamically if a particular preprocessor needs to
be called.

> Kent

Thanks again,


More information about the Tutor mailing list