[Python-Dev] Duck-typing self

2009年2月18日 14:57:35 -0800

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
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to