Re: CONSTRUCT - Module Attributes and Execution Environment

2006-09-03 Thread lazaridis_com
lazaridis_com wrote: > lazaridis_com wrote: > > I would like to change the construct: > > > > if __name__ == '__main__': > ... > > Is there a standard way / naming to wrap "__name__" and other similar > attributes to an encapsulating class? ... see follow-up thread: http://groups.google.com/group

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-27 Thread Fredrik Lundh
Larry Bates wrote: > 1) Don't call a class instance exec, it will mask the built-in > exec statement. "exec" is a reserved word, and cannot be masked: >>> exec = 10 File "", line 1 exec = 10 ^ SyntaxError: invalid syntax -- http://mail.python.org/mailman/listinfo/python-li

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-27 Thread lazaridis_com
lazaridis_com wrote: > I would like to change the construct: > > if __name__ == '__main__': ... Is there a standard way / naming to wrap "__name__" and other similar attributes to an encapsulating class? Something like e.g.: if mod.name ... or if gbl.name ... - "gbl.newAttribute = value" wo

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-25 Thread lazaridis_com
Larry Bates wrote: > lazaridis_com wrote: > > I would like to change the construct: > > > > if __name__ == '__main__': > > > > to something like: > > > > if exec.isMain(): > > > > My (OO thought) is to place a class in an separate code module and to > > instantiate an singleton instance which would

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-25 Thread lazaridis_com
Duncan Booth wrote: > lazaridis_com wrote: > > > Are ther alternative constructs/mechanism available, which could be > > used to add this functionality possiby directly to a code-module? > > How about something along these lines: > > -- auto.py - > import sys, atexit > > de

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-25 Thread lazaridis_com
Fuzzyman wrote: > lazaridis_com wrote: > > I would like to change the construct: > > > > if __name__ == '__main__': > > > > to something like: > > > > if exec.isMain(): > > > > My (OO thought) is to place a class in an separate code module and to > > instantiate an singleton instance which would ke

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-23 Thread Larry Bates
Georg Brandl wrote: > Larry Bates wrote: >> lazaridis_com wrote: >>> I would like to change the construct: >>> >>> if __name__ == '__main__': >>> >>> to something like: >>> >>> if exec.isMain(): >>> >>> My (OO thought) is to place a class in an separate code module and to >>> instantiate an singlet

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-22 Thread Georg Brandl
Larry Bates wrote: > lazaridis_com wrote: >> I would like to change the construct: >> >> if __name__ == '__main__': >> >> to something like: >> >> if exec.isMain(): >> >> My (OO thought) is to place a class in an separate code module and to >> instantiate an singleton instance which would keep

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-22 Thread Larry Bates
lazaridis_com wrote: > I would like to change the construct: > > if __name__ == '__main__': > > to something like: > > if exec.isMain(): > > My (OO thought) is to place a class in an separate code module and to > instantiate an singleton instance which would keep th something like > this: > >

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-22 Thread Duncan Booth
lazaridis_com wrote: > Are ther alternative constructs/mechanism available, which could be > used to add this functionality possiby directly to a code-module? How about something along these lines: -- auto.py - import sys, atexit def main_body(f): if f.func_globals['

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-22 Thread Fuzzyman
lazaridis_com wrote: > I would like to change the construct: > > if __name__ == '__main__': > > to something like: > > if exec.isMain(): > > My (OO thought) is to place a class in an separate code module and to > instantiate an singleton instance which would keep th something like > this: > > clas

CONSTRUCT - Module Attributes and Execution Environment

2006-08-22 Thread lazaridis_com
I would like to change the construct: if __name__ == '__main__': to something like: if exec.isMain(): My (OO thought) is to place a class in an separate code module and to instantiate an singleton instance which would keep th something like this: class ExecutionEnv: def isMain(self)