strings
String manipulation functions.
add_spaces_before_caps(string)
Adds spaces before capital letters in a string if there is a lower-case letter following it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
string |
str
|
The string to add spaces to. |
required |
Returns:
Type | Description |
---|---|
str
|
The string with spaces added before capital letters. |
Examples:
>>> add_spaces_before_caps("HelloWorld")
'Hello World'
>>> add_spaces_before_caps("HelloWorldAGAIN")
'Hello World AGAIN'
Source code in src/nhssynth/common/strings.py
format_timedelta(start, finish)
Calculate and prettily format the difference between two calls to time.time()
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start |
float
|
The start time. |
required |
finish |
float
|
The finish time. |
required |
Returns:
Type | Description |
---|---|
str
|
A string containing the time difference in a human-readable format. |