StringBender 0.2.0
StringBender is a small collection of case-conversion functions… well, actually it’s more than that. It’s a fluent class that inherits from the built-in str.
from stringbender import (
camel, kebob, pascal, snake,
String
)
# =============================================
# EXAMPLES # OUTPUT
s = "Hasta la vista baby"
print(camel(s)) # hastaLaVistaBaby
print(kebob(s) # hasta-la-vista-baby
print(pascal(s)) # HastaLaVistaBaby
print(snake(s)) # hasta_la_vista_baby
# =============================================
# A StringBender method with a str function
# Create an instance of stringbender.String:
s = String("vote*for*pedro")
# Check the default output:
print(s.camel())
# vote*For*Pedro (hmm... this isn't right)
# Pass in a custom delimiter:
print(s.replace("*", " ").camel())
# voteForPedro (Much better!)
# =============================================
# Using a list of delimiters
s = snake(
"Careful man, there's a beverage here!",
delimiters=[",", "'", "!"]
)
print(snake(s))
# careful_man_there_s_a_beverage_here
in PyPi, Python, StringBender Tags: case-conversion, package, PyPi, Python, string.