469,306 Members | 1,771 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,306 developers. It's quick & easy.

What is a "method-wrapper" object?

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.__init__().

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.
import rule
dir (rule) ['__builtins__', '__doc__', '__file__', '__name__', 'rule', 'target',
'time'] print rule.__init__ <method-wrapper object at 0x816c27c> print rule.__init__() None


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?
Jul 18 '05 #1
0 1772

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Giulio | last post: by
2 posts views Thread by Jon Davis | last post: by
4 posts views Thread by Robert W. | last post: by
4 posts views Thread by =?utf-8?B?Qm9yaXMgRHXFoWVr?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.