Skip to content

NightMachinery/PyNight

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyNight

Install

pip install -U pynight

Or install the latest version directly from git:

pip install git+https://github.com/NightMachinery/PyNight.git

To reinstall the latest version:

pip install git+https://github.com/NightMachinery/PyNight.git
pip install --no-deps --force-reinstall git+https://github.com/NightMachinery/PyNight.git

pynight.common_dynamic

from pynight.common_dynamic import (
    DynamicVariables,
    DynamicObject,
    dynamic_set,
    dynamic_get,
)

dynamic_dict = {}
obj = DynamicObject(dynamic_dict, default_to_none_p=True)
obj.x = -13
obj.z = 72
print(
    f"x: {obj.x}, z: {obj.z}, nonexistent_attribute: {obj.nonexistent_attribute or 'some_default_value'}"
)
#: x: -13, z: 72, nonexistent_attribute: some_default_value
with DynamicVariables(obj, x=10):
    print(f"x: {obj.x}, z: {obj.z}")  #: x: 10, z: 72
    with DynamicVariables(obj, x=20):
        print(f"x: {obj.x}, z: {obj.z}")  #: x: 20, z: 72
        obj.x = 99
        obj.y = 81
        obj.z = -6
        print(f"x: {obj.x}, y: {obj.y}, z: {obj.z}")
        #: x: 99, y: 81, z: -6
    print(f"x: {obj.x}, y: {obj.y}, z: {obj.z}")
    #: x: 10, y: 81, z: -6
    #: z and y did NOT get reset as they were not explicitly set in the previous context manager.

    obj.y = 560
print(f"x: {obj.x}, y: {obj.y}, z: {obj.z}")
#: x: -13, y: 560, z: -6
x: -13, z: 72, nonexistent_attribute: some_default_value
x: 10, z: 72
x: 20, z: 72
x: 99, y: 81, z: -6
x: 10, y: 81, z: -6
x: -13, y: 560, z: -6

pynight.common_tqdm

tqdm_telegram

from os import environ

environ['TQDM_TELEGRAM_TOKEN'] = 'xxx'
environ['TQDM_TELEGRAM_CHAT_ID'] = 'xxx'
from pynight.common_tqdm import tqdm, trange
import time

for i in tqdm(range(100)):
    # print(i)
    
    time.sleep(0.1)

About

My Python utility library.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages