[Python-ideas] Functions and Unbound methods
robert2682
robert2682 at verizon.net
Thu Feb 21 03:11:01 CET 2013
Hi,
I'm new; greetings all!
I'm not sure if this is a bug or feature, but it confused me so I thought
I'd raise the issue.
class a:
def b (self):
pass
foo = ('Hello', b)
class c(a):
def d(self):
t = type (self. __class__. foo [1])
print t
t = type (self. __class__. b)
print t
e = c ()
e. d()
prints <type 'function'> for the first print,
and it seems to me it should be an instancemethod
I'm trying to something like this
class EditPage:
additonal_buttons = ()
def __init__ (self):
buts = []
for x in addional_butons:
if isinstance (x [1], types. UnboundMethodType): # fails
because type (x [1]) is function, not UnboundMethod
buts. append ((x [0], types. MethodType (x [1], self)))
else:
buts. append (x)
class TreePage(EditPage):
def EditAsText (self):
pass
additional_buttons = (('EditAsText', EditAsText),)
Thanks
Robert Kaplan
robert2682 at verizon.net
More information about the Python-ideas
mailing list