On Tue, 12 Apr 2022 at 05:14, Christopher Barker <python...@gmail.com> wrote: > > On Mon, Apr 11, 2022 at 11:10 AM Chris Angelico <ros...@gmail.com> wrote: >> >> > I don’t know about anyone else, but I’m not arguing for module scope. I’m >> > arguing against implicit global configuration. >> > >> >> Steven is, as are a few who have agreed that namespaces are the One >> True Way™ to do things. > > > I'm agreeing with namespaces as well -- which I think is different than the > idea of module scope for impict contexts > > Then we are using names, and can use all the rules form managing the cope of > teh names: > > To use the example of one proposed unit syntax: > > distance = 500[miles] > > "miles" would need to be a valid name accessible to that scope -- the writer > of that code can choose exactly what that name is, likely by some sort of > import: > > from my_unit_system import miles > > as oped what I understand was being proposed via a "global registry", which > is that code: > > distance = 500[miles] > > would work even if there were no name "miles" in that namespace(s) -- and it > would, instead go look for it in the global registry -- which could have been > manipulated by the application to mean nautical miles, or statute miles, or > whatever. > > And THAT I think is a bad idea.
It's a good thing we don't have a mutable builtins module, then. Oh right. :) > What I'm not suggesting, because I think it wouldn't be that helpful, and > maybe not possible would be to have something like: > > set_units_registry_to(my_units system) > > and then have: > > distance = 500[miles] > > use my_units_system's definition of miles in that module without having > explicitly imported the name. > The trouble is, you now force everyone to do bulk imports - almost certainly star imports. How are you going to populate the namespace appropriately if not with a star import? What happens if you don't want the entire contents of the module? Having a registry means you can get finer granularity with registration functions, without a massively complex module and submodule system, or heaps of manual imports. ChrisA _______________________________________________ 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/SF5FWCEZN3Y7I5AYLVMJWKU5E7TERFON/ Code of Conduct: http://python.org/psf/codeofconduct/