A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-February/086231.html below:

[Python-Dev] Duck-typing self

[Python-Dev] Duck-typing self [Python-Dev] Duck-typing selfSebastian 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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4