The Industry choice
Kent Johnson
kent3737 at yahoo.com
Tue Jan 4 07:48:17 EST 2005
Alex Martelli wrote:
> 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__ .
The recipe is here (it took me a few minutes to find it, I found the title misleading):
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252158
Kent
More information about the Python-list
mailing list