Re: __getattr__ equivalent for a module

2007-01-15 Thread Maksim Kasimov
Hi Leif, many thanks - it works Leif K-Brooks wrote: > Maksim Kasimov wrote: >> so my question is: how to tune up a module get default attribute if we >> try to get access to not actually exists attribute of a module? > > You could wrap it in an object, but that's a bit of a hack. > > import s

Re: __getattr__ equivalent for a module

2007-01-15 Thread Leif K-Brooks
Maksim Kasimov wrote: > so my question is: how to tune up a module get default attribute if we > try to get access to not actually exists attribute of a module? You could wrap it in an object, but that's a bit of a hack. import sys class Foo(object): def __init__(self, wrapped): s

__getattr__ equivalent for a module

2007-01-15 Thread Maksim Kasimov
Hi, in any python class it is possible to define __getattr__ method so that if we try to get some value of not actually exists instance attribute, we can get some default value. For example: class MyClass: def __getattr__(self, attname): if attname.startswith('a'):