-
Notifications
You must be signed in to change notification settings - Fork 100
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
parse.parse("{c:02d}","100") is None #142
Comments
I don't think this is a desired feature, since the same argument could be made for the following example: >>> "{c:02d}".format(c=100000)
'100000' This would eliminate the feature to specify the number of expected digits. If you expect an integer of unspecified length, you should probably just use |
I am currently using In general it seems to me that aiming for The first equality is not verified when using The second equality is not verified when using |
I like your second point. If the programmer explicitly states that one-digit numbers should be padded with zeros (i.e. However, the first inconsistency you point out seems to be an issue of Python's format function with an impossible solution, as this is not solvable for parse without losing the whole ability of being able to specify the expected padding of a number. But honestly, I think that if you expect three digit numbers, you should specify that in your parse string. This is also a lot less surprising for readers of your code. Basically my argument from above applies here, too. If you as the programmer go out of your way to specify a number which is padded to a width of 2 it should only match strings which contain numbers of that width. May I ask why you use the string |
"{c:02d}".format(c=100)
gives"100"
, thus I would expectparse.parse("{c:02d}","100")
to give<Result () {'c': 100}>
as parse aims to be the inverse of format, but at the moment it gives
None
The text was updated successfully, but these errors were encountered: