Missing interfaces in Python...
Fredrik Lundh
fredrik at pythonware.com
Mon Apr 17 17:35:53 EDT 2006
redefined.horizons at gmail.com wrote:
> If the mechanic class had a "fixIt()" method defined, could I pass it
> any object I wanted
absolutely.
> and then just call the method that I expect to find there
yes.
> or do I need to strictly define the type, or class, of an object that is
> passed to a method.
no. this is Python. no need to negotiate with the compiler; just do what
you want, and the interpreter will tell you when that doesn't work.
also see:
http://en.wikipedia.org/wiki/Duck_typing
</F>
More information about the Python-list
mailing list