Comment

Comment by anentropic

Looks brilliant!

My only suggestion is here:

> It also ignores any leading, trailing, or duplicate delimiters:

    from textcase import case, convert

    print(convert("IOStream", case.SNAKE))             # io_stream
    print(convert("myJSONParser", case.SNAKE))         # my_json_parser
    print(convert("__weird--var _name-", case.SNAKE))  # weird_var_name
In the case of a conversion target that has delimiters (snake, kebab) it might be nice to have an alternative option to preserve such features but normalise them to the target delimiter

i.e.

    print(convert("__weird--var _name-", case.SNAKE, preserve=True))  # __weird__var__name
parent anentropic 1 year ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton