I had a class called rule and a subclass of rule, called bgpRule, in a
file called bgp.py.
I decided to move the rule class to its own file, called rule.py. The
original file did "import rule". I forgot to change bgpRule's
__init__() method from calling rule.__init__() to call
rule.rule.__ini t__().
Amazingly, this caused no immediate error, but rule.__init__() never got
called. When I found the problem, I was puzzled as to why I didn't just
get AttributeError when I called rule.__init__() . A little
investigation led to this:
[rsmith@qwerky agent]$ py
Python 2.2.2 (#1, Apr 5 2003, 13:59:12)
[GCC 3.2.2] on linux2
Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
>>> import rule
>>> dir (rule)[/color][/color][/color]
['__builtins__', '__doc__', '__file__', '__name__', 'rule', 'target',
'time'][color=blue][color=green][color=darkred]
>>> print rule.__init__[/color][/color][/color]
<method-wrapper object at 0x816c27c>[color=blue][color=green][color=darkred]
>>> print rule.__init__()[/color][/color][/color]
None[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
So, what is this "method-wrapper" thingie that doesn't show up in the
module's dir()? I don't see any mention of it in the on-line
documentation. Have I stumbled upon one of those deep dark Python
secrets that mere mortals aren't supposed to know about?
file called bgp.py.
I decided to move the rule class to its own file, called rule.py. The
original file did "import rule". I forgot to change bgpRule's
__init__() method from calling rule.__init__() to call
rule.rule.__ini t__().
Amazingly, this caused no immediate error, but rule.__init__() never got
called. When I found the problem, I was puzzled as to why I didn't just
get AttributeError when I called rule.__init__() . A little
investigation led to this:
[rsmith@qwerky agent]$ py
Python 2.2.2 (#1, Apr 5 2003, 13:59:12)
[GCC 3.2.2] on linux2
Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
>>> import rule
>>> dir (rule)[/color][/color][/color]
['__builtins__', '__doc__', '__file__', '__name__', 'rule', 'target',
'time'][color=blue][color=green][color=darkred]
>>> print rule.__init__[/color][/color][/color]
<method-wrapper object at 0x816c27c>[color=blue][color=green][color=darkred]
>>> print rule.__init__()[/color][/color][/color]
None[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
So, what is this "method-wrapper" thingie that doesn't show up in the
module's dir()? I don't see any mention of it in the on-line
documentation. Have I stumbled upon one of those deep dark Python
secrets that mere mortals aren't supposed to know about?