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
The pyutils.camel_to_snake function does not add an underscore if a capital letter occurs after a non-letter character. For example, came_to_snake("python2Thing") returns python2thing instead of python2_thing. This seems counterintuitive, as it changes the case of the T without adding an underscore as usual.
The text was updated successfully, but these errors were encountered:
Thanks for reporting. I agree, python2_thing would be the expected conversion. It's also what I get when I convert it with PyCharm or Visual Studio Code.
The pyutils function currently uses the same method as python-string-utils, which has this "bug". I'll see if I can find a better way when I find some spare time. If you know any better method, please let me know.
Cito
changed the title
Came to snake doesn't add an underscore after a digit
Camel to snake case conversion doesn't add an underscore after a digit
Sep 22, 2021
Thanks @gosella. I solved it in a similar way by making the minimal necessary change to the existing regex so that the "python2Thing" works as expecetd. If there are edge cases where your regex works better let me know, we can always add more tests and improve.
The
pyutils.camel_to_snake
function does not add an underscore if a capital letter occurs after a non-letter character. For example,came_to_snake("python2Thing")
returnspython2thing
instead ofpython2_thing
. This seems counterintuitive, as it changes the case of theT
without adding an underscore as usual.The text was updated successfully, but these errors were encountered: