is this a python bug?
castor at snafu.de
Thu Jun 7 00:33:13 CEST 2001
thanks for the hints. The very last line says it all,
> > [should] any code [...] be able to blow up the interpreter?
> No. This is (as code like yours demonstrates) surprisingly hard to
> achieve, though.
That's what I'm after. BTW,
> [...] but if I was up to this level of __getattr__
> hackery, I'd have serious thoughts about the design of my application.
I am having serious thoughts, believe me >frantic laugh<
-- no, seriously, the point is here that i try to separate "public" and
"private" attributes, so you can have things like
vc = VC()
vc.foo = 42
vc.keys = 123
print vc[ 'foo'], vc['keys']
and still do, eg,
without the public 'keys' in (1) being an obstruction to the private
(administrative) 'keys' in (2) (see http://home.snafu.de/castor/projects/pylon/).
This is especially practical when you can additionally do
class Y( VC ): pass
y = Y( foo = 42 )
because then the difference between 'instances' and 'mappings'
gets blurred (I admit) to the degree where the decision between using
either a class instance or else a mapping for a given purpose turns
out pointing towards a merger between the two concepts in a great
many cases, which makes VC quite ubiquitious in my code.
Yes, perhaps there could be a more obvious implementation...
More information about the Python-list