[Tutor] Name of a module within itself

alan.gauld@bt.com alan.gauld@bt.com
Sun, 22 Jul 2001 20:57:03 +0100


> Why do you want to use the getattr function?  You could simply say
> 
> def main() :
>     ...
>     HisFoo
>     ...

Cancel my last post, I just realised you want to do it 
from within the same module - like using self in an 
object - sort of...

Like D-Man says I can't think why you'd need to - if you 
know the name you know the object. I guess maybe if you 
were writing some kind of debugger where the object name 
was read from a file or the user maybe? In which case 
maybe you could use eval() or exec() after comparing 
with dir() to check validity?

Alan G