Style Q: Instance variables defined outside of __init__

Alister alister.ware at ntlworld.com
Tue Mar 20 07:14:13 EDT 2018


On 2018年3月20日 08:52:29 +0000, Steven D'Aprano wrote:
> On 2018年3月20日 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.

but why would a functional programmer be programming an OOP class?
-- 
No one becomes depraved in a moment.
		-- Decimus Junius Juvenalis


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /