[Python-ideas] Idea: Named code blocks / inline module declarations

Nick Coghlan ncoghlan at gmail.com
Thu Sep 25 12:30:48 CEST 2014


On 25 September 2014 12:33, Tennessee Leeuwenburg
<tleeuwenburg at gmail.com> wrote:
> Thanks to everyone for the replies! I read them all with interest.
>
> The fundamental issue for me is that you shouldn't just co-opt
> functionality. The semantics of a class is clearly intended to be a class of
> objects -- and instantiatable thing which is a core part of OO design.
> Re-using it for named blocks really just seems like it would be massively
> confusing, particularly if one were to interleave the two.

The metaclass system already allows for fairly significant variations
in "class" semantics. In this case, a metaclass that disallowed
instantiation and bypassed the normal class lookup machinery seems
entirely feasible.

That doesn't seem any more fundamentally confusing than using the same
syntax for normal classes, metaclasses, ABCs, enumerations, database
ORM models, web framework form and view definitions, etc.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list