Simple tools to quickly get the names of multiple variables out of the lines of code where they are defined.
Project description
This package contains the function 'canederlist'
i.e.
Comma And NEwline Delimited Elements Reformatted as LIst of STrings
which allows to reformat a multiline string containing words separated by commas into a list of strings.
This is useful when we have a list of variables and we want to quickly get a list of their names as strings.
usage
The list of variables (i.e. not the variable containing the list, the hardcoded list of variables) must be copied and pasted as argument of canederlist(), enclosed in triple quotes (""").
The function canederlist will remove
- multiple spaces (double or more, but not single spaces)
- newline characters
- triple points ...
- (if selected in the input) round () and square [] parentheses
- (if selected in the input) single spaces and split the remaining elements separated by commas into a list of strings.
example
from canederli import canederlist
columns = [ names,
descriptions,
x_coordinates,
y_coordinates ]
columns_labels = canederlist("""
names,
descriptions,
x_coordinates,
y_coordinates
""")
print(columns_labels)
['names', 'descriptions', 'x_coordinates', 'y_coordinates']
example removing parentheses
from canederli import canederlist
columns = [ names,
descriptions,
x_coordinates,
y_coordinates ]
columns_labels = canederlist("""
names,
descriptions,
x_coordinates,
y_coordinates ]
""",1) # <--- this is the same as setting optional parameter rm_parentheses=True
print(columns_labels)
['names', 'descriptions', 'x_coordinates', 'y_coordinates']
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file canederli-0.0.13.tar.gz
.
File metadata
- Download URL: canederli-0.0.13.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06120cb7eace31f05e02fd8c2c1bb24c20cff14db609e6fc51be73755223ce4f |
|
MD5 | bd9cc4c21a685ed9d7d185e066acf20b |
|
BLAKE2b-256 | 8eee8324493bfbe15c9222af12911bbcc370821dd9171577abdf32d19da52bd1 |
File details
Details for the file canederli-0.0.13-py3-none-any.whl
.
File metadata
- Download URL: canederli-0.0.13-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3a845ab055973ffa093f07666956fe654ca17e0e72b0d223164f80c4acd47b7 |
|
MD5 | 9996c7c0d259f47fc01a57dca1ac1b0e |
|
BLAKE2b-256 | 73ca0d0cea4d3e6f2c33b9ba15a87e14098d701991fda843357688b9854415cd |