Yet Another PEP: Interface Adapter Mechanism __adapt__
Alex Shindich
alex at server01.shindich.com
Sun Mar 25 19:01:54 EST 2001
It sounds like your PEP suggests adding Strategy pattern behavior to all
Python objects. My question is WHY? Implementing strategy pattern,
i.e. asking object if it supports a particular interface, is trivial. In
fact, you can do it easily by using introspection, i.e. hasattr (obj,
'blah').
There are other ways of implementing strategies -- flyweights, query
interface, etc.
Another way of looking at your PEP is to say that you are asking for
Python Java-like interfaces. In my humble opinion, interface driven
programming is not as needed in Python because of introspection. Instead
of asking if the object supports a set of methods, you can ask if
object supports individual methods.
--
Alex Shindich
mailto:alex at shindich.com
Visit http://www.shindich.com/
--
Posted from adsl-63-194-17-248.dsl.lsan03.pacbell.net [63.194.17.248]
via Mailgate.ORG Server - http://www.Mailgate.ORG
More information about the Python-list
mailing list