Seite 1 von 1

bound method in einer Funktion aufrufen...??

Verfasst: Dienstag 21. Juni 2011, 13:24
von mutetella
Hallo,

kann mir mal jemand folgendes Verhalten erklären:

Code: Alles auswählen

In [13]: class Test(object):
   ....:     def __init__(self, foo):
   ....:         self.foo = foo
   ....:     
   ....:     def get_foo(self):
   ....:         return self.foo
   ....:     
   ....:     

In [14]: def test():
   ....:     print 'bar'
   ....:     
   ....:     

In [15]: def call_it(call):
   ....:     call()
   ....:     
   ....:     

In [16]: t = Test('bar')

In [17]: t.get_foo()
Out[17]: 'bar'

In [18]: call_it(t.get_foo)

In [19]: call_it(test)
bar
Warum ruft 'call_it' die Methode 'get_foo' nicht auf?

mutetella

Re: bound method in einer Funktion aufrufen...??

Verfasst: Dienstag 21. Juni 2011, 13:27
von EyDu
return ;-)

Re: bound method in einer Funktion aufrufen...??

Verfasst: Dienstag 21. Juni 2011, 13:47
von mutetella
O Mann, das darf doch nicht wahr sein!!!!!

:oops: :oops: :oops: