Why do only callable objects get a __name__?
Terry Reedy
tjreedy at udel.edu
Mon Nov 18 16:11:08 EST 2013
On 11/18/2013 3:13 PM, John Ladasky wrote:
> Of course, I have used __name__ for years in the common expression "if __name__ == "__main__") to determine whether a particular module is being run or merely imported.
This true statement invalidates your subject line ;-). All modules have
a __name__. The main module has the name (__name__) '__main__'. (A file
named '__main__.py' also has special meaning. If one does 'python -m
package' on a command line and 'package' is a directory with
'__init__.py', 'package/__main__.py' is executed as the main module
'__main__'.
> 1. WHY do only callable objects get a __name__?
Why do you think this? Is there a mistake in the doc?
--
Terry Jan Reedy
More information about the Python-list
mailing list