infering the number of args a function takes at runtime

S

sniffer

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


TIA
 
S

sniffer

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

TIA

Thanks guys , i think this should work for me.btw as enquired i am
working o a mvc thingie where in need to call functions in a
controller,and pass the arguments as recieved from the end user so i
need to make sure that the number of arguments passed from the front
end are correct or not in the context of the function being called
 
L

Lie Ryan

Thanks guys , i think this should work for me.btw as enquired i am
working o a mvc thingie where in need to call functions in a
controller,and pass the arguments as recieved from the end user so i
need to make sure that the number of arguments passed from the front end
are correct or not in the context of the function being called

In python, usually you'll just pass the them all and maybe catch errors.

def callback(*args, **kargs):
try:
return func(*args, **kargs)
except TypeError:
print('An error happened')
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top