Skip to main content

Slytherin

Slytherin is a collection of useful but lonely functions and classes that don't belong to other libraries.

Installation

pip install slytherin

Usage

collections

cross_lists()

from slytherin.collections import cross_lists
list1 = [1, 2, 3]
list2 = [4, 5]
list3 = [[6, 7], [8, 9]]

cross_lists(list1, list2, list3)

outputs:

[(1, 4, [6, 7]),
 (1, 4, [8, 9]),
 (1, 5, [6, 7]),
 (1, 5, [8, 9]),
 (2, 4, [6, 7]),
 (2, 4, [8, 9]),
 (2, 5, [6, 7]),
 (2, 5, [8, 9]),
 (3, 4, [6, 7]),
 (3, 4, [8, 9]),
 (3, 5, [6, 7]),
 (3, 5, [8, 9])]
cross_lists([list1, list2, list3])

also outputs:

[(1, 4, [6, 7]),
 (1, 4, [8, 9]),
 (1, 5, [6, 7]),
 (1, 5, [8, 9]),
 (2, 4, [6, 7]),
 (2, 4, [8, 9]),
 (2, 5, [6, 7]),
 (2, 5, [8, 9]),
 (3, 4, [6, 7]),
 (3, 4, [8, 9]),
 (3, 5, [6, 7]),
 (3, 5, [8, 9])]

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))

Metadata

Release files for slytherin 2020.11.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for slytherin 2020.11.12
File Size Uploaded
slytherin-2020.11.12.tar.gz 14.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for slytherin 2020.11.12
File Interpreter ABI Platform
slytherin-2020.11.12-py3-none-any.whl Python 3 none any Details

Total release size: 38.6 kB

Release files / slytherin-2020.11.12.tar.gz

Download URL slytherin-2020.11.12.tar.gz
Size 14.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b2b051c6c504272fbdd59fc1f6060af1050b3d914605a71cbec39743d59e22aa
BLAKE2b-256 checksum
How to use checksums
79d45521525310836b235d1bddaa5ce9f0bcbbb149e42c97e6662d77e49f79dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

Release files / slytherin-2020.11.12-py3-none-any.whl

Download URL slytherin-2020.11.12-py3-none-any.whl
Size 23.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
11b04414b01491e1485a0d2e9f479fe76806f41a53f495d1b7ee01f67464f6f1
BLAKE2b-256 checksum
How to use checksums
809489a1bd42da38459652a1d4148288dc73e25ee6f9a2cbfb2e9fe1c89241e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page