web hosting and development forums
Web Design and Development Forums Archive


Index - Python programming forum

how can i know that func named 'invokeapp' is exists


Post reply

Hi, if I have a string, such as 'invokeapp', how can i know that func named 'invokeapp' is exists as well? That is i wanna invoke any func by string. But i need to chech whether that func was exist.
exec 'try: invokeapp'; except: print" the function does not exist";else:print "it exists"' Something like that Exec and try-except are the keys to this problem
if do that, the python will raise a exceptiog about 'str hasnot callable'
Why?
for a param string, there isnt callable on it.
See globals() built-in function.
I don't get what you mean
at first, we may convert that string to func, which func can do this? Like int ('12')
No. You won't do it like this. I think there is no such function.
jomanda, Do you really need to use this horrid exec stuff? How about a dictionary of names to functions? The added benefit is that you can control which functions can be invoked
i wanna pass a string to a class, so that that class can invoke that directly.




Dubai Forum | Paris Forum | Webmaster Forum | Vegan Forum | Brisbane Forum | 3D Forum | Jobs in Dubai | Jobs in London | London UK Classifieds
Archive script by RedHo.com