
April 8, 2022
5:26 a.m.
On Fri, 8 Apr 2022 at 10:15, Daniel Pope <lord.mauve@gmail.com> 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