function to find the modification date of the project

James Mills prologic at shortcircuit.net.au
Mon Jan 19 23:43:49 CET 2009


On Tue, Jan 20, 2009 at 8:39 AM, James Mills
<prologic at shortcircuit.net.au> wrote:
> On Tue, Jan 20, 2009 at 7:44 AM, Joe Strout <joe at strout.net> wrote:
>> This isn't a question, but something I thought others may find useful (and
>> if somebody can spot any errors with it, I'll be grateful).
>>
>> We had a case recently where the client was running an older version of our
>> app, and didn't realize it.  In other languages I've avoided this by
>> displaying the compile date in the About box, but of course Python doesn't
>> really have a meaningful compile date.  So, instead we're now displaying the
>> latest modification date of any .py file in the project.  Here's the
>> function that finds that:
>
> You know you could just store a __version__
> attribute in your main library (__init__.py). :)
>
> Normally in my project, this version string
> is stored in __version__.py in my library and
> fetched in by my library's __init__.py and setup.py
> for distribution. Works great :)

Also I'd like to point out that your method is not
very reliable as the modification time of those
files could change at any moment. Consider
unix systems for instnace where you could do:

touch *

And poof, you're modification times are now
the current time!

Sorry for finding flaws in your approach! :)

cheers
James



More information about the Python-list mailing list