What is a "method-wrapper" object?
roy at panix.com
Tue Sep 23 03:08:01 CEST 2003
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
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 at 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.
>>> import rule
>>> dir (rule)
['__builtins__', '__doc__', '__file__', '__name__', 'rule', 'target',
>>> print rule.__init__
<method-wrapper object at 0x816c27c>
>>> print rule.__init__()
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?
More information about the Python-list