The Industry choice

Alex Martelli aleaxit at yahoo.com
Sun Jan 2 17:25:47 EST 2005


Roy Smith <roy at panix.com> wrote:

> Stefan Axelsson <crap1234 at hotmail.com> wrote:
> > Yes, ignoring most of the debate about static vs. dynamic typing, I've
> > also longed for 'use strict'.
> 
> You can use __slots__ to get the effect you're after.  Well, sort of; it
> only works for instance variables, not locals.  And the gurus will argue
> that __slots__ wasn't intended for that, so you shouldn't do it.

There's a simple, excellent recipe by Michele Simionato, on both the
online and forthcoming 2nd edition printed Cookbook, showing how to do
that the right way -- with __setattr__ -- rather than with __slots__ .


Alex



More information about the Python-list mailing list