Pre/Postconditions with decorators

Stephen Thorne stephen.thorne at gmail.com
Sun Jan 9 05:45:16 EST 2005


On 08 Jan 2005 15:50:48 -0800, Paul Rubin
<"http://phr.cx"@nospam.invalid> wrote:
> Stephen Thorne <stephen.thorne at gmail.com> 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).
Working under the assumption we cannot change the existing standard library.

> > 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.
So we can't use this for a case where we have an extremely large list
then ;). Its an O(n) operation to just call a function that takes a
list of a specific type.

Stephen.



More information about the Python-list mailing list