parse icon indicating copy to clipboard operation
parse copied to clipboard

explicit string format as {name_:s} does not work

Open martinResearch opened this issue 5 years ago • 5 comments

Hi,

It seems that when specifying the format as :s in the formating string then parse does not work:

form = "test_{name:s}"
s = form.format(name="hello")# getting 'test_hello'
parse.parse(form , s) # getting None

Should we add a section elif type == 's': in _handle_field ?

martinResearch avatar Aug 13 '20 19:08 martinResearch

Oof. Unfortunately, parse deviates from format for that one letter, s. In parse it means "whitespace". In format, when used, it means "the default string format".

I actually mis-read the format spec when writing parse and missed the mention of s :(

r1chardj0n3s avatar Aug 29 '20 00:08 r1chardj0n3s

Ok. Maybe this behaviour could be controlled trough an new optional argument with default value set up to keep default behaviour unchanged to avoid breaking code that relies on it ?

martinResearch avatar Aug 29 '20 10:08 martinResearch

I don't really like that as an option, as it will be very confusing. I think to fix it I'd need to make it a new major release which is backwards-incompatible in this one way.

r1chardj0n3s avatar Sep 10 '20 23:09 r1chardj0n3s

I see. Is that something you would want to do ?

martinResearch avatar Sep 12 '20 11:09 martinResearch

Not really, but I think I'm going to have to ;-)

r1chardj0n3s avatar Jan 13 '21 23:01 r1chardj0n3s