20 May
2009
20 May
'09
6:17 a.m.
No, I would say “too much” here is importing a module not guaranteed to be installed, for creating something as simple as a version. I'd prefer the above to be::
$ cat _version.py # This is an auto-generated file. Use magicbean to update. version = "0.9.33" $
Or my preferred way: $cat foobar/__init__.py __version__ = "0.9.33" and import foobar should not trigger code execution anyway IMHO so $ python -c 'import foobar; print foobar.__version__' 0.9.33
I still like the approach of having it in a module that can be imported to automatically have the name bound to an appropriate value.
Yes, agree 100% the KISS approach is always the best. Regards, Antonio