Checking for attribute in the current module with getattr( )
Joakim Hove
hove at phys.ntnu.no
Tue Aug 7 15:04:22 EDT 2001
Hello,
I have written a quite small and simple Python script, schematically
looking like this:
#!/usr/local/bin/python
def func1(arg1,arg2):
....
def func2(arg1,arg2):
....
## Start of main program
if hasattr(???,"func1"): # <- Problematic line!
print "This module defines a function \"func1\""
else:
print "No function \"func1\" defined"
Now, as indicated I don't really know what object to send in to the
hasattr function, indicated with "???" - is what I'm trying to do
possible, and how should I in case do it?
Best regards
Joakim Hove
--
==== Joakim Hove www.phys.ntnu.no/~hove/ =======================
|| Institutt for fysikk (735) 93637 / E3-166 | Skøyensgate 10D ||
|| N - 7491 Trondheim hove at phys.ntnu.no | N - 7030 Trondheim ||
================================================= 73 93 31 68 =========
More information about the Python-list
mailing list