Python library of useful but lonely functions and classes
Project description
Slytherin
Slytherin is a collection of useful but lonely functions and classes that don't belong to other libraries.
Installation
pip install slytherin
Usage
get_size(obj)
The get_size() method calculates the memory footprint of a Python object recursively.
The exclude_objects argument is a list of objects and is optional with the default value of None. Any object in the exclude_objects list will be excluded from the recursive search. It can be used to avoid double counting the size when objects point to each other.
from slytherin import get_size
get_size(obj=[1,2,3], exclude_objects=None)
import pandas as pd
get_size(obj=pd.DataFrame({'id': range(1000), 'name':['Godric', 'Helga', 'Rowena', 'Salazar']*250}))
colour(text, text_colour, style, background_colour)
The colour() method can be used to add colour to printing text.
The colour are integers from 0 to 7:
- black: 0
- red: 1
- green: 2
- yellow: 3
- blue: 4
- purple: 5
- cyan: 6
- white: 7
The style argument is an integer between 0 and 5:
- normal: 0
- bold: 1
- underline: 2
- negative1: 3
- negative2: 5
from slytherin import colour
print(colour(text='Hello world!', text_colour=4))
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
Hashes for slytherin-2020.4.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be4a8e69f8fa1e8bedc874bf5fe033f65ba95fc422d13e60f1c1043d775a10af |
|
MD5 | 5e260d09066c8289ccb3242f24adc9be |
|
BLAKE2b-256 | a9a157aa3e9fe0d0925e2a414f9f8dedbf34e0c915366cda90b86c48e8d2eebd |