[Python-Dev] Duck-typing self
Sebastian Rittau
srittau at jroger.in-berlin.de
Wed Feb 18 23:32:09 CET 2009
Hi!
I am curious why the following will not work in Python:
class foo(object):
def bar(self):
print self.attr
class duck(object):
attr = 3.14
foo.bar(duck())
Is it a design decision that duck-typing self does not work or is there a
technical reason? From a practical standpoint it seems that being able to
duck-type self has merit, for example in unit testing complex classes.
- Sebastian
More information about the Python-Dev
mailing list