Last active
December 10, 2015 12:18
-
-
Save broqdev/4433729 to your computer and use it in GitHub Desktop.
Revisions
-
broqdev revised this gist
Jan 2, 2013 . 1 changed file with 5 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,14 +3,16 @@ def __init__(self): self._func = None def callDerivedFunc(self): # self._func() # call bound method # self._func(self) # call unbound method method = self._func method(self) # call unbound method class Bar(Foo): def __init__(self): super(Foo, self).__init__() self._func = Bar.hello # unbound method # self._func = self.hello # bund method def hello(self): print 'Hello' -
broqdev created this gist
Jan 2, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ class Foo(object): def __init__(self): self._func = None def callDerivedFunc(self): # self._func() # wrong method = self._func method(self) # right class Bar(Foo): def __init__(self): super(Foo, self).__init__() self._func = Bar.hello def hello(self): print 'Hello' bar = Bar() bar.callDerivedFunc()