[Tutor] Finding the version # of a module, and py module problem

Philip Semanchuk philip at semanchuk.com
Fri Aug 6 11:09:17 EDT 2010


On Aug 6, 2010, at 10:20 AM, Richard D. Moores wrote:

> On Thu, Aug 5, 2010 at 18:47, Philip Semanchuk  
> <philip at semanchuk.com> wrote:
>>
>> it's just a question of whether or not
>> the module in question exposes any kind of a version attribute.  
>> There's no
>> standard, unfortunately. The most popular convention seems to be  
>> via an
>> attribute called __version__, but I've also seen __VERSION__,  
>> VERSION, and
>> version.
>>
> Here's one more way:
>>>> import gmpy
>>>> gmpy.__version__
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> AttributeError: 'module' object has no attribute '__version__'
>>>>
>>>> gmpy.version()
> '1.12'

That's the nice thing about standards -- there are so many to choose  
from!  =)

Thanks for pointing that out; I'll update my code.

bye
Philip



More information about the Python-list mailing list