[Python-Dev] Duck-typing self (original) (raw)
Sebastian Rittau srittau at jroger.in-berlin.de
Wed Feb 18 23:32:09 CET 2009
- Previous message: [Python-Dev] lifting of prohibition against readlines inside a "for line in file" in Py3?
- Next message: [Python-Dev] Duck-typing self
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-Dev] lifting of prohibition against readlines inside a "for line in file" in Py3?
- Next message: [Python-Dev] Duck-typing self
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]