[issue45956] Add scanf regular expressions to re

2021-12-01 Thread Maxwell Bernstein


Change by Maxwell Bernstein :


--
resolution:  -> rejected
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45956] Add scanf regular expressions to re

2021-12-01 Thread Eric V. Smith

Eric V. Smith  added the comment:

Maxwell: thank you for your contribution. 

I agree that these don’t belong in the re module.

I think a personal library or something on PyPI (logically equivalent to 
more-itertools) would be more appropriate. 

I suggest closing this as rejected.

--
nosy: +eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45956] Add scanf regular expressions to re

2021-12-01 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

The scanf() translation table primarily serves as a way to learn regex syntax 
for people who only know scanf syntax.  

It would defeat the educational purpose to immortalize the translation as fixed 
constants.  For the most part, people are better off writing their own 
customizations, for example not using [+-] unless a sign is known to be present.

Also, the table in the docs provides a translation between scanf tokens and 
regex patterns, but it does not assign names to each pattern.  The PR adds 
names but makes confusing choices.  

For example, \S+ in regex notation means "longest sequence contiguous sequence 
of non-space characters".  In the PR, '\S+' is aliased with "whitespace" which 
is the opposite of its usual meaning.

Another problem with the new names is that they take C scanf specific 
definitions and put them in a Python context where we use the words 
differently.  For example, "octal" in scanf means "[-+]?[0-7]+" but in Python 
oct(333) would give '0o515' which includes an 'o' and does not include a '+'.

Overall, I think it would be a mistake to put C world specific aliases into 
Python world.  Instead, it would be better to just leave the table for 
education purposes as it is now.

--
assignee:  -> rhettinger
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45956] Add scanf regular expressions to re

2021-12-01 Thread Maxwell Bernstein


Change by Maxwell Bernstein :


--
keywords: +patch
pull_requests: +28111
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/29885

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45956] Add scanf regular expressions to re

2021-12-01 Thread Maxwell Bernstein


New submission from Maxwell Bernstein :

The documentation for the `re` module suggests several regular expressions for 
use in simulating `scanf()`. Provide these directly in the `re` module.

--
components: Library (Lib)
messages: 407491
nosy: tekknolagi
priority: normal
severity: normal
status: open
title: Add scanf regular expressions to re
versions: Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com