Given an identifier, return the words that identifier represents, whether in camel case, underscore-separated, etc. >>> WordSet.parse("camelCase") ('camel', 'Case') >>> WordSet.parse("under_sep") ('under', 'sep') Acronyms should be retained >>> WordSet.parse("firstSNL") ('first', 'SNL') >>> WordSet.parse("you_and_I") ('you', 'and', 'I') >>> WordSet.parse("A simple test") ('A', 'simple', 'test') Multiple caps should not interfere with the first cap of another word. >>> WordSet.parse("myABCClass") ('my', 'ABC', 'Class') The result is a WordSet, so you can get the form you need. >>> WordSet.parse("myABCClass").underscore_separated() 'my_ABC_Class' >>> WordSet.parse('a-command').camel_case() 'ACommand' >>> WordSet.parse('someIdentifier').lowered().space_separated() 'some identifier' Slices of the result should return another WordSet. >>> WordSet.parse('taken-out-of-context')[1:].underscore_separated() 'out_of_context' >>> WordSet.from_class_name(WordSet()).lowered().space_separated() 'word set' >>> example = WordSet.parse('figured it out') >>> example.headless_camel_case() 'figuredItOut' >>> example.dash_separated() 'figured-it-out'
Class Method | from |
Undocumented |
Class Method | parse |
Undocumented |
Method | __getitem__ |
Undocumented |
Method | camel |
Undocumented |
Method | capitalized |
Undocumented |
Method | dash |
Undocumented |
Method | headless |
Undocumented |
Method | lowered |
Undocumented |
Method | space |
Undocumented |
Method | trim |
>>> WordSet.parse('foo bar').trim('foo') ('bar',) |
Method | trim |
Remove the item from the beginning of the set. |
Method | trim |
Remove the item from the end of the set. |
Method | underscore |
Undocumented |
Class Variable | _pattern |
Undocumented |
Remove the item from the beginning of the set. >>> WordSet.parse('foo bar').trim_left('foo') ('bar',) >>> WordSet.parse('foo bar').trim_left('bar') ('foo', 'bar') >>> WordSet.parse('').trim_left('bar') ()