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 th something like > > this: > > > > class ExecutionEnv: > > def isMain(self) > > if CALLING_MODULE.__name__ == '__main__': > > return true > > else > > return false > > > > exec = ExecutionEnv() > > > > How to I get access to the CALLING_MODULE ? > > > > - > > > > Are ther alternative constructs/mechanism available, which could be > > used to add this functionality possiby directly to a code-module? > > > Two thoughts: > > 1) Don't call a class instance exec, it will mask the built-in > exec statement.
ok, I understand. > 2) IMHO all the suggestions are way more complicated than > if __name__ == "__main__" and are not SOP for most pythoneers. > I know what the former construct means/does. I have to > decipher your class to figure our what the latter does and it > doesn't really save you any code or provide a performance > enhancement. "Clarity for Pythoneers" is not a main requirement of the project. The main requirements (The network of requirements is not yet fully documented): http://case.lazaridis.com/wiki/Code The related issue: http://case.lazaridis.com/ticket/5 > -Larry -- http://mail.python.org/mailman/listinfo/python-list