>The use of getattr here seems unfortunate

Unfortunate how? It's a perfect for what I want here ... remember the context 
is such that the lazily stored value is always truthy (I assert this elsewhere).

>   I'm not sure why you want to avoid an __init__ method.

Why do you want to keep it?  The more code you write the more bugs you write. 
Who knows, maybe I screw up the argument pass to the super __init__. Maybe I 
screw up the super reference. Didn't Einstein say make it as simple as 
possible, but no simpler?

Personally, I find the ability of Python to subclass without overriding the 
constructor very elegant. I don't believe the other languages I've worked in 
can do this (C++, C#, Java)... or if there is a way it's a bit scary and 
discouraged. Whereas skipping the __init__ seems to be a standard part of the 
Python OO development process.

Again, this is just the lazy eval pattern. In C#, for example, I'd write my 
constructors but refer to _lazy only in the foo function and in it's 
declaration line (which would explicitly default initialize it).

At any rate, the second idiom is very pretty to me, I'm keeping it unless a 
compelling argument is presented. Thanks for the kibbutzing though, the first 
idiom was poor form, as I suspected.


-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to