Boa (String Conversion)

1.1.0 · maintenance · verified Fri Apr 10

Boa is a Python package (version 1.1.0) designed for normalizing and converting strings to snakecase. It efficiently handles various cases, including stripping punctuation and transforming camelCase or PascalCase strings into snake_case. For example, 'User Buys Item' becomes 'user_buys_item'. The last release was in 2017, indicating that the project is no longer actively developed but remains available for its specific string conversion utility.

Warnings

Install

Imports

Quickstart

The `boa.constrict()` function is the main entry point for converting strings to snakecase. It handles various input formats.

import boa

my_str_camel = 'toInfinityAndBeyond'
my_str_spaces = 'Welcome to planet Earth!'
my_str_hyphens = 'a-string-with-hyphens'

snake_camel = boa.constrict(my_str_camel)
snake_spaces = boa.constrict(my_str_spaces)
snake_hyphens = boa.constrict(my_str_hyphens)

print(f"'{my_str_camel}' -> '{snake_camel}'")
print(f"'{my_str_spaces}' -> '{snake_spaces}'")
print(f"'{my_str_hyphens}' -> '{snake_hyphens}'")

# Example of typical usage
user_event = 'User Buys Item'
processed_event = boa.constrict(user_event)
print(f"'{user_event}' -> '{processed_event}'")

view raw JSON →