2012-03-02 10 views
21

Da dove viene la convenzione sull'uso di variabili di metadati private come __author__ all'interno di un modulo?Qual è l'origine di __author__?

This Il thread di mailinglist in Python sembra suggerire una discussione al riguardo nel 2001, ma a quanto pareva la convenzione era già in circolazione.

Oltre a questo, posso trovare solo this PEP on package metadata, che sembra influente ma tangente al meglio.

Mi piacerebbe provare a trovare del materiale esplicito sull'argomento in modo che il mio strumento di documentazione possa analizzare correttamente queste variabili di metadati.

risposta

17

La mia ipotesi è, è dai vecchi tempi in cui i metadati della confezione non erano comuni allora. In PEP 8 si consiglia di utilizzare la variabile di livello superiore __version__ per conservare l'id di revisione del sistema di controllo delle versioni in uso. Questo risale al 2001-05-01. PEP 396 sostituisce questo per gli attributi module __version__.

Per __author__ è presente un post dalla mailing list di python dev, relativo a questo argomento. Questo risale al 2001-03-01. L'autore interroga l'uso di __author__: "Quali sono le prossime? __cute_signoff__?".

Poiché non vi è alcuna menzione nei PEP, non dobbiamo preoccuparci di __author__. I metadati di imballaggio sono comunque nostri amici.

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

Dato questo probabilmente non c'è modo di analizzare in modo affidabile \ _ \ _ autore \ _ \ _ o \ _ \ _ crediti \ _ \ _ attributi. – itsafire