Hello everyone,
I'm the author of PEP 823 (None-aware access operators) and 824 (None-coalescing operators). Together they would add the following operators to the language ?., ?[ ], ?? and ??=. It was brought to my attention that IPython uses ? to access help on an object.
https://ipython.readthedocs.io/en/stable/interactive/python-ipython-diff.html#accessing-help
Based on a quick search, it looks like you're using a regex to detect it.
|
_help_end_re = re.compile( |
|
r"""(%{0,2} |
|
(?!\d)[\w*]+ # Variable name |
|
(\.(?!\d)[\w*]+|\[-?[0-9]+\])* # .etc.etc or [0], we only support literal integers. |
|
) |
|
(\?\??)$ # ? or ?? |
|
""", |
|
re.VERBOSE, |
|
) |
I'd be interested to know if the PEP proposals would break that use case or if you'd be able to work around it. My initial thought would be that as long as no line break isn't inserted in a bad spot, it should continue to work if ? is only detected directly at the start and end of a line.
Edit: While for ?. and ?[ ] it will depend if the line break is placed between the characters, ?? might be more difficult. As a conditional operator similar to and and or, it will be at the beginning or end in multiline expressions (depending on the specific formatting).
The discussion threads with more details
In particular the issue with IPython was raised in this post: https://discuss.python.org/t/pep-823-none-aware-access-operators/109159/5.
Thanks for your time!
Hello everyone,
I'm the author of PEP 823 (None-aware access operators) and 824 (None-coalescing operators). Together they would add the following operators to the language
?.,?[ ],??and??=. It was brought to my attention that IPython uses?to access help on an object.https://ipython.readthedocs.io/en/stable/interactive/python-ipython-diff.html#accessing-help
Based on a quick search, it looks like you're using a regex to detect it.
ipython/IPython/core/inputtransformer2.py
Lines 580 to 588 in 93dde62
I'd be interested to know if the PEP proposals would break that use case or if you'd be able to work around it.
My initial thought would be that as long as no line break isn't inserted in a bad spot, it should continue to work if?is only detected directly at the start and end of a line.Edit: While for
?.and?[ ]it will depend if the line break is placed between the characters,??might be more difficult. As a conditional operator similar toandandor, it will be at the beginning or end in multiline expressions (depending on the specific formatting).The discussion threads with more details
In particular the issue with IPython was raised in this post: https://discuss.python.org/t/pep-823-none-aware-access-operators/109159/5.
Thanks for your time!