What is my module name?
crj003 at yahoo.com
Thu Jun 28 14:49:30 CEST 2001
> I have a module with a function below I
> use __name__ to return the module name.
> However, when I call the function from
> outside, it returns '__builtin__'. Is
> there a way to have this function return
> the module name regardless of where it
> is called?
> def myName(): return __name__
You don't need to do that. If you want to know the name of the module
it is available after importing the module.
# code for myName
Now all you have to do is import the module:
# And here is where you can get the name of the module
name_of_module = Name.__name__ # = 'Name'
More information about the Python-list