Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Width and precision restrictions are not captured exactly the same as format() generates in some situations #99

Open
purpleskyfall opened this issue Dec 23, 2019 · 1 comment
Labels

Comments

@purpleskyfall
Copy link

Some inconsistence occured when parse the follow string:

>>> import parse
>>> pattern = ' {:4} {:2} {:4} {:1} {:12.3f}'
>>> line1 = ' SUWN  A    1 P -3062023.278'
>>> line2 = ' URUM  A    1 P   193030.186'
>>> parse.parse(pattern, line1) # correct
<Result ('SUWN', ' A', '   1', 'P', -3062023.278) {}>
>>> parse.parse(pattern, line2) # incorrect
<Result ('URUM', 'A ', ' 1 P', ' ', 193030.186) {}>
@r1chardj0n3s
Copy link
Owner

This one is quite tricky, since the width stuff is really hard to get right when constructing the regex internally. I think there's going to need to be some tricky re-plumbing of the way I handle width and precision of string and number parsing to make your case work :(

@r1chardj0n3s r1chardj0n3s changed the title Inconsistent for string parse. Width and precision restrictions are not captured exactly the same as format() generates in some situations Jan 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants