is this a python bug?

Wolfgang Lipp castor at snafu.de
Wed Jun 6 18:33:13 EDT 2001


Mike, 

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

(1)
	vc = VC()
	vc.foo = 42
	vc.keys = 123
	print vc[ 'foo'], vc['keys']

and still do, eg,

(2)
	print vc._.keys()

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

(3)
	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...


-wolf






More information about the Python-list mailing list