infering the number of args a function takes at runtime

James Mills prologic at shortcircuit.net.au
Sun Dec 7 23:50:57 EST 2008


On Mon, Dec 8, 2008 at 2:45 PM, Chris Rebert <clp at rebertia.com> wrote:
> On Sun, Dec 7, 2008 at 8:39 PM, sniffer <adi at lspl.net> wrote:
>> hi all,
>> i am a python newbie, in a project currently doing i need to find out
>> the number of arguments that a function takes at runtime.? Is this
>> possible ,if so how do i do this,i ve looked through the python
>> documentation but couldnt find anything.any help will be great
>
> You want inspect.getargspec() or one of its friends in the `inspect`
> module. See http://docs.python.org/library/inspect.html#inspect.getargspec

Also, I have to ask: Why do you need to do this ?
Please show some code samples of what you're trying to achieve
and what the problem is ?

cheers
James

-- 
--
-- "Problems are solved by method"



More information about the Python-list mailing list