__author__

Mike C. Fletcher mcfletch at rogers.com
Fri Oct 1 14:16:43 EDT 2004


Peter L Hansen wrote:
...

> I suspect a majority of modules actually use VERSION in preference
> to __version__, maybe because many authors didn't interpret the
> PEP8 comment as widely as some did.

I'd actually be suspicious of that suspicion, I can't recall every 
seeing VERSION used, while __version__ is something I've seen time and 
time again.  Those times I've wanted to check an installed package's 
version I've always used

import package
package.__version__

in the interpreter.  Never even occurred to me to use VERSION (and it's 
never shown up in a dir() of a package when I've wanted to do this (that 
I can recall)).

> (I've tended to use VERSION, I believe, but I'm moving towards
> using a build.xml file containing a variety of meta-information
> for the entire package, rather than an embedded constant.)

Ah yes, much easier to work with ;) :

    import package
    if [int(i) for i in package.__version__.split('.')[:2]] > [2,3]:
       blah()

versus:

    import package
    tag = findVersionTag(parseXMLFile(findXMLFile( package )))
    if (findMajorVersion(tag),findMinorVersion(tag)) > (2,3):
       blah()

Just teasing, you know I believe that XML is the solution to all 
problems in the universe which can't be addressed *directly* with Java 
;) .  As long as you're exposing APIs that mean client libraries never 
have to do the actual finding and parsing of the XML file, having your 
"get version" API integrated into your package-management code can be 
very useful for keeping them in sync.

Still, __version__ is a pretty simple API...

Smile!
Mike

________________________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://www.vrplumber.com
  http://blog.vrplumber.com




More information about the Python-list mailing list