CONSTRUCT -

Georg Brandl g.brandl-nospam at gmx.net
Sun Sep 3 04:02:53 EDT 2006


lazaridis_com wrote:
> I would like to fulfill the following task:
> 
> The construct:
> 
> if __name__ == '__main__':
> 
> should be changed to something like:
> 
> if identifier.name == '__main__':
> 
> The term "identifier" should be selected based on the meaning of the
> __double-underscore-enclosure__ of the entities.
> 
> -
> 
> What I would need to know is:
> 
> a) what would be the correct term for "identifier"?

import sys
class _identifier:
    def __getattr__(self, name):
        return sys._getframe(1).f_globals['__%s__' % name]
identifier = _identifier()

Georg



More information about the Python-list mailing list