On 11/15/06, Josiah Carlson <[EMAIL PROTECTED]> wrote:
>
> "George Sakkis" <[EMAIL PROTECTED]> wrote:
> > As I wrote in my last reply to Nick though, I question Python's right to 
> > perform
> > such limited forms of design-by-contract-like assertions ("why not add
> > a precondition
> > on __add__(self,other) to enforce isinstance(other, self.__class__)
> > ?") when it refuses to formalize interfaces for sequences, iterators
> > et al.
>
> Because 5, 5+0j, 5.0 are different types.  To not be able to add any of
> them because they are different types, would be silly.  Note that
> Decimal is a different beast, which is why I don't include it.  There's
> also string + unicode (at least in 2.x), and if some sort of
> unicode view makes it into 3.x, view + unicode.

You missed my point; I wasn't seriously suggesting that there should
be more checks (hence the quotes), but rather the contrary, that
checking whether len() returns a non-negative integer does very little
to the overall consistency scheme of things.

Pre-conditions, post-conditions, invariants are a stricter form of API
conformance than just checking whether a method with a specific name
is there, and Python is unwilling to check even that.

George
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to