Common Python shortcuts and utilities that speed up debug workflows
Project description
cmstuff
Common Python shortcuts and utilities that speed up debug workflows by 30%.
Installation
pip install cmstuff
For development:
git clone https://github.com/Williams/cmstuff.git
cd cmstuff
pip install -e .
Overview
The library provides a set of commonly used functions and shortcuts to make coding in Python easier. It includes shortcuts for printing, file searching, directory management, introspection, and logging.
Introspection utilities
doc(obj)— print or return documentation from an objectclassname(obj)— return the class name of an objectmefun(obj)— return all callable non-class attributesmethods(obj)— return a list of methods (excluding magic methods)group(obj)— return a mapping of types to their respective attributesStat(obj)— group and display all types in an objectfilterout(type_, obj)— filter attributes by typefilterout_base_attrs(obj)— list properties not inherited from base classesfilterstr(s, obj)— filter attributes containing a substring
Path utilities
HOME— path to user home directorydesktop()— path to the desktopcdesktop()— change working directory to the desktoppypath()— path to the Python installationopendir(dir)— open a directory in the file explorersearch_files(fname)— recursively search for files by keyword
Other utilities
concat(*items)— concatenate items into a space-separated stringcls()— clear the consolesetargs(arg, *args)— setsys.argvconvenientlyget_logger(...)— create a custom logger with sensible defaultsget_caller_module()— get the module of the calling code
Example
import cmstuff as cm
class Example:
def __init__(self):
self.name = "John"
self.age = 30
self._id = "12345"
self.other_name = "Doodleman"
def display_info(self):
print(f"Name: {self.name}, Age: {self.age}")
def full_name(self):
return f"{self.name} {self.other_name}"
# get an object
example = Example()
# filter the methods and attributes that are relevant to you
filtered_attrs = cm.filterstr("name", example)
# it returns a list so you can do further processing
print(filtered_attrs) # Output: ['full_name', 'name', 'other_name']
# If you think this is cool try
# cm.Stat(example).show()
Author
Williams — williamusanga22@gmail.com
License
MIT
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cmstuff-1.1.0.tar.gz.
File metadata
- Download URL: cmstuff-1.1.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.20 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a07ad956e81bd2e6fdcecc0e6561eee4d4aa8d9ad0f6de9c281989584b082390
|
|
| MD5 |
ee90f609180579724fdf9bf2f8cab260
|
|
| BLAKE2b-256 |
70d8d094a7874305d7843f6a60999ce68d4d75e817b46102543731d98aff406f
|
File details
Details for the file cmstuff-1.1.0-py3-none-any.whl.
File metadata
- Download URL: cmstuff-1.1.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.20 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69ec5a119b64f11644f6cb4e6bd9707c02a3336b7dc5a9b665b34da1742166ff
|
|
| MD5 |
46afe438e178f6b081bb621e66a40908
|
|
| BLAKE2b-256 |
a5912be99df4965c47ceb43ddf3cb24c5482cf1494ccbb2727a64b9e2f705387
|