🐫 Convert strings (and dictionary keys) between snake case, camel case and pascal case in Python. Inspired by Humps for Node
Likely abandoned. No release or commit for years (last release over 4 years ago).
Consider insteadcamel-converterPythie’s Index: 841.7M downloads/moCompare →
pip install pyhumps
Convert strings (and dictionary keys) between snake case, camel case and pascal case in Python. Inspired by Humps for Node.
Jan 11, 2021: An open call for contributors:
Please email me at nficano@gmail.com.
Installation
To install humps, simply use pipenv (or pip, of course):
$ pipenv install pyhumps
Usage
Converting strings
import humps
humps.camelize("jack_in_the_box") # jackInTheBox
humps.decamelize("rubyTuesdays") # ruby_tuesdays
humps.pascalize("red_robin") # RedRobin
humps.kebabize("white_castle") # white-castle
Converting dictionary keys
import humps
array = [{"attrOne": "foo"}, {"attrOne": "bar"}]
humps.decamelize(array) # [{"attr_one": "foo"}, {"attr_one": "bar"}]
array = [{"attr_one": "foo"}, {"attr_one": "bar"}]
humps.camelize(array) # [{"attrOne": "foo"}, {"attrOne": "bar"}]
array = [{'attr_one': 'foo'}, {'attr_one': 'bar'}]
humps.kebabize(array) # [{'attr-one': 'foo'}, {'attr-one': 'bar'}]
array = [{"attr_one": "foo"}, {"attr_one": "bar"}]
humps.pascalize(array) # [{"AttrOne": "foo"}, {"AttrOne": "bar"}]
Checking character casing
import humps
humps.is_camelcase("illWearYourGranddadsClothes") # True
humps.is_pascalcase("ILookIncredible") # True
humps.is_snakecase("im_in_this_big_ass_coat") # True
humps.is_kebabcase('from-that-thrift-shop') # True
humps.is_camelcase("down_the_road") # False
humps.is_snakecase("imGonnaPopSomeTags") # False
humps.is_kebabcase('only_got_twenty_dollars_in_my_pocket') # False
# what about abbrevations, acronyms, and initialisms? No problem!
humps.decamelize("APIResponse") # api_response