[IronPython] Duck typing / builders

Dino Viehland dinov at exchange.microsoft.com
Wed Dec 13 21:38:14 CET 2006

Yes, IronPython is completely duck typed, but I'm not certain how your x.bar & x.foo ties into that.

It almost sounds like you want foo and bar to be properties.  You can do that with:

class baz(object):
        def foo(self):
                print "I've been called"
                return 42
        def bar(self):
                print "Me too!"
                return 23

a = baz()

which will print "Me too!" and return 23.  You can then also do anything with this object from there, eg:

a.xyz = 23

Traditionally duck typing refers to "if it looks like a duck, and quacks like a duck, it's a duck".  That's more like:

class balloon(object):
        def blowup(self):
                print 'inflating balloon'

class bomb(object):
        def blowup(self):
                print 'exploding'

def InflateIt(obj):


Both call the blowup method disregarding the fact that blowing up a ballon and blowing up a bomb are two rather different concepts - but they both look like the same duck.

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Hamilton Verissimo
Sent: Wednesday, December 13, 2006 11:19 AM
To: users at lists.ironpython.com
Subject: [IronPython] Duck typing / builders

Does IronPython support any form of duck typing? Ideally I want somethign like


And record this invocations to generate, well, other things.


hamilton verissimo
hammett at castlestronghold.com
users mailing list
users at lists.ironpython.com

More information about the Ironpython-users mailing list