CONSTRUCT -

Steve Holden steve at holdenweb.com
Tue Sep 5 15:39:06 CEST 2006


lazaridis_com wrote:
> Georg Brandl wrote:
> 
>>lazaridis_com wrote:
>>
>>>Georg Brandl wrote:
>>>
>>>>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.
>>>
>>>...
>>>
>>>
>>>>import sys
>>>>class _identifier:
>>>>    def __getattr__(self, name):
>>>>        return sys._getframe(1).f_globals['__%s__' % name]
>>>>identifier = _identifier()
>>>
>>>ok, I understand.
>>>
>>>this one would work with modules.
>>>
>>>but how would look a more general solution, which would work with
>>>objects too?
>>
>>Why can't you try to come up with something yourself? You should have
>>had enough exposure to the Python language by now.
>>
>>Georg
> 
> 
> I am not a (python) domain expert.
> 
> Thus I am asking here for available standard-solutions, before I
> implement an own solution.
> 
There is no standard solution for the problem you mention.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Skype: holdenweb       http://holdenweb.blogspot.com
Recent Ramblings     http://del.icio.us/steve.holden




More information about the Python-list mailing list