2012-03-02 17 views
21

¿De dónde viene la convención de usar variables de metadatos privados como __author__ dentro de un módulo?¿Cuál es el origen de __author__?

This El hilo de la lista de correo de Python parece insinuar alguna discusión al respecto en 2001, pero por lo que parece, la convención ya se había lanzado en la naturaleza.

Aparte de eso, solo puedo encontrar this PEP on package metadata, que parece influyente pero tangencial en el mejor de los casos.

Me gustaría tratar de encontrar material explícito sobre el tema para que mi herramienta de documentación pueda analizar estas variables de metadatos con éxito.

Respuesta

17

Supongo que es de los viejos tiempos cuando el empaquetado de metadatos no era común entonces. En PEP 8, se recomienda utilizar la variable __version__ de nivel superior para mantener el id de revisión del sistema de control de versiones en uso. Esto data de 2001-05-01. PEP 396 está reemplazando esto para atributos de módulo __version__.

Para __author__ hay una publicación de la lista de distribución de python dev sobre este asunto. Este se remonta a 2001-03-01. El autor cuestiona el uso de __author__: "¿Qué sigue? __cute_signoff__?".

Como no hay mención en las PEP, no tenemos que preocuparnos por __author__. Los metadatos de empaquetado son nuestros amigos de todos modos.

http://mail.python.org/pipermail/python-dev/2001-March/013328.html

 
Ping just checked in this: 

> Log Message: 
> Add __author__ and __credits__ variables. 
> 
> 
> Index: tokenize.py 
> =================================================================== 
> RCS file: /cvsroot/python/python/dist/src/Lib/tokenize.py,v 
> retrieving revision 1.19 
> retrieving revision 1.20 
> diff -C2 -r1.19 -r1.20 
> *** tokenize.py 2001/03/01 04:27:19 1.19 
> --- tokenize.py 2001/03/01 13:56:40 1.20 
> *************** 
> *** 10,14 **** 
> it produces COMMENT tokens for comments and gives type OP for all operators.""" 
> 
> ! __version__ = "Ka-Ping Yee, 26 October 1997; patched, GvR 3/30/98" 
> 
> import string, re 
> --- 10,15 ---- 
> it produces COMMENT tokens for comments and gives type OP for all operators.""" 
> 
> ! __author__ = 'Ka-Ping Yee ' 
> ! __credits__ = 'first version, 26 October 1997; patched, GvR 3/30/98' 
> 
> import string, re 

I'm slightly uncomfortable with the __credits__ variable inserted 
here. First of all, __credits__ doesn't really describe the 
information given. Second, doesn't this info belong in the CVS 
history? I'm not for including random extracts of a module's history 
in the source code -- this is more likely than not to become out of 
date. (E.g. from the CVS log it's not clear why my contribution 
deserves a mention while Tim's doesn't -- it looks like Tim probably 
spent a lot more time thinking about it than I did.) 

Anothor source of discomfort is that there's absolutely no standard 
for this kind of meta-data variables. We've got __version__, and I 
believe we once agreed on that (in 1994 or so :-). But __author__? 
__credits__? What next -- __cute_signoff__? 
+0

Teniendo en cuenta esto probablemente no hay manera de analizar de forma fiable \ _ \ _ autor \ _ \ _ \ _ \ o créditos _ \ _ \ _ atributos. – itsafire

Cuestiones relacionadas