PEP 245

Alex Shindich shindich at itginc.com
Thu Apr 5 12:18:28 EDT 2001


>Common practice in Python is to do not even that, but just use the object
as
>given. If it doesn't have the methods then there will be an exception.
>Heavy unit testing is necessary anyway.
>
>Even checking for existence of getitem and so on seems too rigorous to me
to
>use in every day Python. That's silly, you don't even normally check if
your
>input is actually an integer.

I was trying to make an example of the interface splitting... But you are
right. No body checks the method's presence before calling it. In fact, it's
been a while since I have used hasattr for that. I even screwed up and wrote
'has_attr' ;)

The code should have looked like:
# Client code
son = Son ()
son.writeRequirements ()
son.design ()
son.implement ()

>some formal definition of interface may sound like a cool idea, just not
one that should
>have anything to do with Python...
Amen to that!

Regards,

Alex Shindich



-- 
Posted from mailgw1.itginc.com [209.49.52.22] 
via Mailgate.ORG Server - http://www.Mailgate.ORG



More information about the Python-list mailing list