You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When both the width and zero specifiers are present, this should give enough information that the string to be matched has to have a minimum width of width, instead of a maximum (or in addition to a maximum):
importparseparse.extract_format("03d", None)
{'type': 'd',
'width': '3',
'zero': True,
'align': None,
'fill': None,
'extra_types': None,
'format': 'd'}
parse.parse("{:d}{:03d}", "1012")
# yields <Result (101, 2) {}>, but this can't be a result of the format string; (1, 12) is the only possible match
I realize that there are some tricky cases here such as with the possibility of negative signs, but it seems like the width could be calculated a bit more precisely here. Thoughts?
The text was updated successfully, but these errors were encountered:
I'm marking this one as a wishlist item because I do not believe the current implementation of parse() can be made to enforce widths as precisely as you need. Because parse() is based off some increasingly-complicated regexes, rather than a proper syntax parser, it those regexes start getting really complicated when you want to think about enforcing that "the width of text captured for a number is N characters" especially when the number can be in a variety of formats.
When both the
width
andzero
specifiers are present, this should give enough information that the string to be matched has to have a minimum width ofwidth
, instead of a maximum (or in addition to a maximum):I realize that there are some tricky cases here such as with the possibility of negative signs, but it seems like the width could be calculated a bit more precisely here. Thoughts?
The text was updated successfully, but these errors were encountered: