Pre/Postconditions with decorators

Paul Rubin http
Sat Jan 8 18:50:48 EST 2005

Stephen Thorne <stephen.thorne at> writes:
> Unresolved Problems:
> 1) How do you handle duck types, i.e. a method that accepts StringIO,
> cStringIO or any other object that has a .readlines(), .seek() and
> .read() method?

That should really be done through having those classes inherit a
file-operations mixin, or else through interfaces (which might get
added to Python).

> 2) How do you turn off the type checking for production code?

It should be left on.  Leaving it in for development and turning it
off for production is like wearing a parachute during ground training
and taking it off once you're in the air.

More information about the Python-list mailing list