[Tutor] (no subject)

Danny Yoo dyoo at hashcollision.org
Thu Feb 19 19:06:45 CET 2015


On Thu, Feb 19, 2015 at 9:23 AM, rakesh sharma
<rakeshsharma14 at hotmail.com> wrote:
> Greetings !!
> Hi all,
> what the meaning of the line at the start of the python file
> __author__ = "user"


Hi Rakesh,


It's assigning a variable '__author__' with the value "user".

Python libraries typically have some kind of "metadata" that talks
about the library, and one way to express this metadata is to assign
to certain variables like what you're seeing here.


I can look at a particular module, and see if it has an '__author__':

########################################
>>> import tarfile
>>> tarfile.__author__
'Lars Gust\xe4bel (lars at gustaebel.de)'

>>> import io
>>> io.__author__
"Guido van Rossum <guido at python.org>, Mike Verdone
<mike.verdone at gmail.com>, Mark Russell <mark.russell at zen.co.uk>,
Antoine Pitrou <solipsis at pitrou.net>, Amaury Forgeot d'Arc
<amauryfa at gmail.com>, Benjamin Peterson <benjamin at python.org>"
########################################

That being said, it's not a requirement, so not all library modules have this.

########################################
>>> import xml
>>> xml.__author__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute '__author__'
########################################


And as a beginner, you probably don't need to worry about assigning
authorship to your own programs: you should know that you wrote them.
:P

When you start working with larger teams of people, it's helpful
because you want to direct development questions to the folks who own
those files.  Authorship is a rough approximation to find the right
person in charge.


More information about the Tutor mailing list