osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Style Q: Instance variables defined outside of __init__


On Tue, 20 Mar 2018 02:43:13 -0400, Terry Reedy wrote:

> I think a claim that in all programs all attributes should be set *in*
> __init__, as opposed to *during* initialization, is wrong.  All
> attribute setting is side-effect from a functional view (and usually
> 'bad' to a functionalist).  There is no reason to not delegate some of
> it to sub-init functions when it makes sense to do do.  There is good
> reason to do so when it makes the code easier to understand *and test*.

That is really well said Terry, thank you for articulating what I was 
thinking but couldn't find the words for.



-- 
Steve