Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #59910

Re: Why do only callable objects get a __name__?

From Terry Reedy <tjreedy@udel.edu>
Subject Re: Why do only callable objects get a __name__?
Date 2013-11-18 16:11 -0500
References <b8a1c0cb-a52e-466b-af2a-64059f4e8be3@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.2865.1384809081.18130.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Why do only callable objects get a __name__? John Ladasky <john_ladasky@sbcglobal.net> - 2013-11-18 12:13 -0800
  Re: Why do only callable objects get a __name__? John Ladasky <john_ladasky@sbcglobal.net> - 2013-11-18 12:38 -0800
  Re: Why do only callable objects get a __name__? Ian Kelly <ian.g.kelly@gmail.com> - 2013-11-18 13:43 -0700
    Re: Why do only callable objects get a __name__? John Ladasky <john_ladasky@sbcglobal.net> - 2013-11-18 13:02 -0800
      Re: Why do only callable objects get a __name__? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-18 23:37 +0000
        Re: Why do only callable objects get a __name__? John Ladasky <john_ladasky@sbcglobal.net> - 2013-11-18 22:10 -0800
  Re: Why do only callable objects get a __name__? Terry Reedy <tjreedy@udel.edu> - 2013-11-18 16:11 -0500
    Re: Why do only callable objects get a __name__? John Ladasky <john_ladasky@sbcglobal.net> - 2013-11-18 13:26 -0800
  Re: Why do only callable objects get a __name__? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-18 23:21 +0000
    Re: Why do only callable objects get a __name__? John Ladasky <john_ladasky@sbcglobal.net> - 2013-11-18 22:36 -0800
      Re: Why do only callable objects get a __name__? Steven D'Aprano <steve@pearwood.info> - 2013-11-19 07:08 +0000

csiph-web