Random useful code categorized into modules.
Project description
Package: generallibrary
Random useful code categorized into modules.
Installation
pip install generallibrary
Features (Generated by getLocalFeaturesAsMD)
| Module | Name | Explanation |
|---|---|---|
| code | debug | Easily call eval() on an arbitrary amount of evaluation strings. |
| code | getLocalFeaturesAsMD | Convert local callable objects that don't start with _ to a markdown table for a README. |
| functions | Operators | Automatic operator definitions for classes. |
| functions | SigInfo | Handles a callable along with it's parameters. |
| functions | calculate | Automatically fills variables of a formula in a string then evaluates it. |
| functions | defaults | Set default values of a given dictionary, option to overwrite None values. |
| iterables | SortedList | Controls a sorted list in ascending order. |
| iterables | addToDictInDict | Add a key-value argument to a dict inside a dict, automatically creates dict. |
| iterables | addToListInDict | Add a value to a list inside a dictionary, automatically creates list. |
| iterables | combine | Create a list of dicts containing every unique combination from given object (Can be tuples). |
| iterables | depth | Get depth of an object by recursively checking the first value. |
| iterables | dictFirstValue | Get first 'random' value of a dictionary or None. |
| iterables | exclusive | Returns a new dictionary without keys. |
| iterables | getFreeIndex | Get the first free integer index of dictionary starting at 0. |
| iterables | getIterable | Returns the iterable values of a tuple, list or dict. Otherwise False. |
| iterables | getRows | Get rows as lists in list from a tuple, list or dict (where it discards keys). |
| iterables | inclusive | Returns a new dictionary without keys not in keys. |
| iterables | isIterable | See if an obj is a tuple, list or dict. |
| iterables | iterFirstValue | Get first 'random' value of an iterable or None. |
| iterables | joinWithStr | Like str.join() but it casts the values to strings first, also takes dict. |
| iterables | uniqueObjInList | Controls whether a unique object should be present in a list or not. |
| object | attributes | Get all attributes of an object that don't start with __, as a dictionary. |
| object | getClassFromMethod | Retrieve class object from a method object. |
| object | getsize | Get a sum of sizes from an object and it's members in bytes. |
| object | initBases | Decorator function for class to automatically initalize all inherited classes. |
| time | Timer | Callable class to easily time things and print. |
| time | sleep | Normal sleep function from time package. |
| types | getBaseClassNames | Get all base classes from an object's class as lowered names. |
| types | getBaseClasses | Get all base classes from an object's class. |
| types | hasMethod | Return whether an object has a specific callabale attribute. |
| types | strToDynamicType | Try to convert a string to bool, None, int or float. |
| types | typeChecker | Check type(s) of an object. |
| values | clamp | Return clamped value between minimum and maximum. |
| values | confineTo | Confine this value, but unlike clamp it subtracts diff * n to create an 'infinite' effect. |
| values | doubleRectify | Return 0 if it's between min and max, otherwise it returns difference from edge of range. |
| values | inrange | Return whether value is between minimum and maximum. |
| values | rectify | Return 0 if it's below threshold, otherwise difference. |
| values | sign | Get sign value based on threshold that defaults to 0. |
| versions | VerInfo | Get info regarding current Python, OS and conditional functionalities. |
Usage example
from generallibrary import clamp
print(clamp(-3.2, -1, 1))
# >>> -1
Releases
generallibrary 2.1
- Added properties to
VerInfo()for conditional functionalities- caseSensitive
- positionalArgument
- pathDelimiter
- pathRootIsDelimiter
- pathRootHasColon
generallibrary 2.0
- Put all features inside
__init__.pyto make importing easier - Added Operators
- Added VerInfo
- Added SigInfo
- Changed addToListInDict to allow *args and returns entire dict
- Added addToDictInDict
- Added initCaller decorator
- Added includeObject parameter to getBaseClasses
- Added includeDefaulted parameter to getSignatureNames
- Added combine
- Added uniqueObjInList
Todo
- Redo iterables.py, namely getIterable() and isIterable(), it's a mess
- Handle local and pre-releases for versions.VerInfo
- Make SigInfo's callableObject changeable and store all variables when setting them
- DuckTyping class for versions.py
- PackageVersion class for versions.py
- Change getLocalFeaturesAsMD to allow cls or even obj and also *args.
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
generallibrary-2.3.2.tar.gz
(26.0 kB
view details)
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 generallibrary-2.3.2.tar.gz.
File metadata
- Download URL: generallibrary-2.3.2.tar.gz
- Upload date:
- Size: 26.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88a067855381b4cb111d399411d55af727ad5cd73100a1da0c8e8f2e9fc43bdc
|
|
| MD5 |
a284235176cab69d69b0627d984d102e
|
|
| BLAKE2b-256 |
7d2b534cda77b24937ac77a6e37bfba920b5a334f1c6f4b1faf0bc5a241db5fe
|
File details
Details for the file generallibrary-2.3.2-py3-none-any.whl.
File metadata
- Download URL: generallibrary-2.3.2-py3-none-any.whl
- Upload date:
- Size: 29.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ed49c83593cca05565fd56ac2ea7de7c0b781c74b94ce8c1a7e3267646affc9
|
|
| MD5 |
7282c59dacb2883dcdedfcc087294b53
|
|
| BLAKE2b-256 |
c2d25c00572c8fa493e530e5354f2b8c1cf95bbc1fd90d5db4a20bcf0b534a55
|