Linux application deployment

Alex Martelli aleaxit at yahoo.com
Mon Sep 6 13:09:23 EDT 2004


On 2004 Sep 06, at 18:06, Robert Brewer wrote:
    ...
>> def whereami(): return os.path.abspath(sys.modules[__name__].__file__)
>
> Shorter version for the local directory:
>
> import os.path
> localDir = os.path.dirname(__file__)
>
> I don't see any reason to make it a callable...?

By encapsulating this I believe you stand a better chance of easily 
fixing across Python version changes, platform oddities, etc.  Of 
course, __name__ should then be an argument (otherwise this function 
will always report the whereabouts of the module it was imported from) 
-- and if you don't know how to import anything then importing the 
'utilities' module containing this is also going to be problematic, of 
course;-).


Alex




More information about the Python-list mailing list