On Fri, 8 Apr 2022 at 11:26, Malthe <mbo...@gmail.com> wrote:
> Perhaps `some_regex = re::compile(r"...")` could work.
>
> That is, <dotted-path>::<name-to-import> to delineate the import.

As I mentioned in the Discourse thread, this syntax chimes with Rust
(and C++, and also PHP, triggering fond memories of Paamayim
Nekudotayim).

There are two problems, sort of on the minor side:

First, there's one place in Python where this can occur and that is in
slices: xs[start::step] means the slice from start to the end with a
step of step. But xs[(module::name)] is currently a syntax error, so
you could just require parentheses to disambiguate the case. Still, it
is confusing if you write something slightly more complex like xs[1 +
math::factorial(n)] and you get NameError: name 'math' is not defined.

Secondly, it precludes importing just a module object, you have to
import a name from a module. Maybe using a module object in an
expression is niche and can be disregarded. Or a solution could be to
allow an expression like (re::) to import a module object, which I
guess we could get used to. Also fun would be to consider what ::name
does - access to current globals without the global keyword?

I think this discussion is better suited to the python-ideas mailing
list, or the Discourse thread I linked earlier.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/MO524TQHUR7PMUWOZ4PBQAXDMOOF2KFP/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to