[Python-Dev] Re: Declarative imports

2022年4月08日 03:29:32 -0700

On Fri, 8 Apr 2022 at 10:15, Daniel Pope <[email protected]> wrote:
> But, your proposed syntax is not usable because it is ambiguous. Exactly what 
> you propose is already used for decorators in a way that the parser would not 
> be able to distinguish a decorator from an import expression. Consider:
>
> @ham.spam() # import expression or decorator?
>
> def eggs():
> ...
>
> This currently parses as a decorator and for backwards compatibility that 
> must not change, which means that import expressions would be usable in some 
> contexts and not others purely based on what follows them.
Perhaps `some_regex = re::compile(r"...")` could work.
That is, <dotted-path>::<name-to-import> to delineate the import.
@breakfast.ham::spam
def eggs(): pass
Cheers
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/VXOSHFQDLPI5KXVNXWKFMRZOZHYJLZL5/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to