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):
@property
def foo(self):
print "I've been called"
return 42
@property
def bar(self):
print "Me too!"
return 23
a = baz()
a.bar
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):
obj.blowup()
InflateIt(bomb())
Or
InflateIt(balloon())
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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hamilton
Verissimo
Sent: Wednesday, December 13, 2006 11:19 AM
To: [email protected]
Subject: [IronPython] Duck typing / builders
Does IronPython support any form of duck typing? Ideally I want somethign like
x.foo
x.bar
And record this invocations to generate, well, other things.
Thanks
--
Cheers,
hamilton verissimo
[EMAIL PROTECTED]
http://www.castlestronghold.com/
_______________________________________________
users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com