A package to Keep In Mind your constants and call them anytime anywhere
Project description
kim a.k.a Keep In Mind
kim is a public pip librairy. It's purpose is to keep in mind your variable so you can call update and delte them anytime anywhere. It's especially useful for very large project where it can be tough to call your variable in a recursive algorithme.
Install
kim is compatible with python>=3.5 and doesn't require any other package from pip.
pip install kim-python
How to use
Create
To create a variable which you would like kim to remember use CreateOrUpdate :
import kim
kim.CreateOrUpdate(category="my_category", name="my_variable", value="Hello World")
print(kim.my_category.my_variable)
print(type(kim.my_category.my_variable))
Hello World
<class 'str'>
Note that if your using an IDE with IntelliSense, you'll have the option to autofill kim.my_category.my_variable, but it requires one compilation.
Update
You can update your variables also by calling CreateOrUpdate:
import kim
kim.CreateOrUpdate(category="my_category", name="my_variable", value="Hello World")
print(kim.my_category.my_variable)
print(type(kim.my_category.my_variable))
kim.CreateOrUpdate(category="my_category", name="my_variable", value=["Hello world", {"foo": "bar"}])
print(kim.my_category.my_variable)
print(type(kim.my_category.my_variable))
Hello World
<class 'str'>
['Hello world', {'foo': 'bar'}]
<class 'list'>
Delete
To erase every created variables call Clear :
import kim
kim.CreateOrUpdate(category="my_category", name="foo", value=100)
kim.CreateOrUpdate(category="my_category", name="bar", value={"hello world": 1})
try:
print(kim.my_category.foo)
except Exception as e:
print(e)
try:
print(kim.my_category.bar)
except Exception as e:
print(e)
kim.Clear()
try:
print(kim.my_category.foo)
except Exception as e:
print(e)
try:
print(kim.my_category.bar)
except Exception as e:
print(e)
100
{'hello world': 1}
module 'kim' has no attribute 'my_category'
module 'kim' has no attribute 'my_category'
To delete a category use Remove without specify which variable to delete :
import kim
kim.CreateOrUpdate(category="my_category", name="my_variable", value="Hello World")
kim.Remove(category="my_category")
try:
print(kim.my_category.my_variable)
except Exception as e:
print(e)
module 'kim' has no attribute 'my_category'
To delete all the variable use Clear
Read
In addtion of fetching your variables with kim.my_category.my_variable you can use the function variables_dict to get a dictionary of the saved variables :
import kim
kim.CreateOrUpdate(category="my_category", name="my_variable", value="Hello World")
print(kim.variables_dict())
{'my_category': {'my_variable': 'Hello World'}}
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
File details
Details for the file kim-python-0.0.3.tar.gz.
File metadata
- Download URL: kim-python-0.0.3.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46c97a13c368b2e7ad19adad48ec90ed3aa6da4e1efc7e3d3ac4130374b62f71
|
|
| MD5 |
7ef605c0cee3ad8eb3f5a19ba655d4f8
|
|
| BLAKE2b-256 |
6601910807f632daa3561ef3acf4c80584984a30fe9837d91a74865e84931fa9
|