Horrible abuse of __init_subclass__, or elegant hack?

Alan Gauld alan.gauld at yahoo.co.uk
Wed Mar 31 20:29:45 EDT 2021


On 01/04/2021 00:14, Chris Angelico wrote:

> On a scale of 1 to "submit this to The Daily WTF immediately", how bad
> is this code? :)

The only worthwhile test of code quality is whether a new member
of the team, competent in the language but not an expert can
understand the code in two readings or less. If they can it's
good enough. Maintenance is always the highest cost in any
significant project so good code must be maintainable.

In this case I'd venture they'd encounter init_sublass() for the
first time, do some research and on the second reading make sense
of it. So, it's good to go.

Whether it's an optimal design or not is a different matter.
There's always more than one way to do it.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Python-list mailing list