On 7/26/19 12:23 PM, Ricky Teachey wrote: >> >> The class statement works in this fashion. >> > I would argue there are at least 2 significant reasons why a separate > namespace would be preferred over using class in this way:
[...] > 2. using class means that all of the "new style class" machinery > is at work-- for good or for ill-- when working in your > class-defined namespace. so if, for example, you create a > descriptor and instantiate it inside a class namespace, the > descriptor __get__ method will be invoked when accessing the > descriptor via the class name. this could be very limiting in > certain cases. Flat is better than nested. Yes, at some point, flat becomes unweildy, and you have to do something. Or not. Simple is better than complex. With every one of these nesting constructs (e.g., comprehensions, classes, functions, methods, modules), there are possibly subtle scoping and name lookup rules. For every new such construct, there are new and possibly subtle such rules. At some point, the expressiveness of a language disappears into the noise of complexity (no, I don't have a citation, just lots of experience). There Is Only One Way To Do It. Enough said. I'm pretty sure I'm not a luddite, but I'm also pretty sure that new ways to capture ("close over") a value and/or to encapsulate state is a long way from your father's executable pseudo code. Yes, at some point, every little throwaway automation script takes on a life of its own, and you have to make a choice. Please choose the simplicity of small reusable building blocks (aka modules full of functions; or classes full of methods if you must) rather than yet another way to inline your encapsulation. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/R24IUB5VSCEHF7LRHA4FQXD55N7O2YEJ/ Code of Conduct: http://python.org/psf/codeofconduct/