Dennis Lee Bieber
3/21/2010 6:08:00 PM
On Sun, 21 Mar 2010 16:57:40 +0000 (UTC), kj <no.email@please.post>
declaimed the following in gmane.comp.python.general:
> Just accessing attributes looks a bit dangerous to me, due to bugs
> like typing
>
> i.typo = 'foo'
>
> when what you meant is
>
> i.type = 'foo'
>
> I tried fixing this by mucking with __setattr__, but I didn't hit
> on a satisfactory solution (basically, I couldn't find a good,
> self-maintaining, way to specify the attributes that were OK to
> set from those that weren't). Is there anything built-in?
>
I don't believe it was created for the purpose, but check the
documentation on __slots__() {library ref 3.2.4.4 for Python 2.5}
> Regarding properties, is there a built-in way to memoize them? For
> example, suppose that the value of a property is obtained by parsing
> the contents of a file (specified in another instance attribute).
> It would make no sense to do this parsing more than once. Is there
> a standard idiom for memoizing the value once it is determined for
> the first time?
>
Pickle, Shelve? Maybe in conjunction with SQLite3...
--
Wulfraed Dennis Lee Bieber KD6MOG/AE
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/