Style Q: Instance variables defined outside of __init__

Steven D'Aprano steve+comp.lang.python at pearwood.info
Tue Mar 20 04:52:29 EDT 2018


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




More information about the Python-list mailing list