Used to store variables permanently, which can be read directly after importing into the library.
Project description
Permanent Variable Tool
中文文档请往下查看
pvt.new(variable:str, value:Any=None) -> None
Functionality
Creates/updates variable files in ./data/ directory
Usage Example
pvt.new("user_profile", {"name": "John", "age": 28}) # Serializes to string
pvt.new("system_flag") # Creates empty file
pvt.read(variable:str) -> str
Critical Notes
- Always wrap in try-except:
try:
config = pvt.read("app_config")
except FileNotFoundError:
initialize_defaults()
pvt.delete(variable:str) -> None
Security Notice
- Deletion is permanent. Recommended safety check:
if os.path.exists(pvt.data_dir + "/" + variable + ".var"):
pvt.delete("temp_data")
pvt.find (variable name: str) -> Bool
Use examples
Bool = pvt.find(str)
print(Bool) # True / False
pvt.list() -> dict
Functionality
Reads all .var files from C:\pvt_data and converts contents to Python values
Value Mapping Rules
$value.false→False$value.true→True$value.ellipsis→...- Other content remains as string
Usage Example
variables = pvt.list() # Returns {'debug': True, 'max_retries': '5'}
pvt.copy(variable name 1:str, variable name 2:str) -> None
function
Find variable name 1.var from C:\pvt_data and copy its value to variable name 2.var. If variable name 1.var is not available, write None in variable name 2.var after prompt.
###Examples of use
pvt.copy("str1","str2") #copies the value in str1 to str2, creates if str2 does not exist, sets str2 to None if str1 does not exist and prompts an error.
永久变量工具 (Permanent Variable Tool)
Please check the English documents up.
pvt.new(变量名:str, 值:Any=None) -> None
功能
在./data/目录中创建/更新变量文件
使用示例
pvt.new("user_profile", {"name": "张三", "age": 28}) # 序列化为字符串
pvt.new("system_flag") # 创建空文件
pvt.read(变量名:str) -> str
重要说明
- 必须使用try-except包裹:
try:
config = pvt.read("app_config")
except FileNotFoundError:
initialize_defaults()
pvt.delete(变量名:str) -> None
安全提示
- 删除操作不可逆。建议进行安全检查:
if os.path.exists(pvt.data_dir + "/" + variable + ".var"):
pvt.delete("temp_data")
pvt.find(变量名:str) -> Bool
使用示例
Bool = pvt.find(str)
print(Bool) # True / False
pvt.list() -> dict
功能
从C:\pvt_data读取所有.var文件并转换内容为Python值
值转换规则
$value.false→ 布尔值False$value.true→ 布尔值True$value.ellipsis→ 省略号对象...- 其他内容保留原始字符串格式
使用示例
variables = pvt.list() # 返回如 {'debug': True, 'max_retries': '5'}
pvt.copy(变量名1:str, 变量名2:str) -> None
功能
从C:\pvt_data寻找变量名1.var,并复制其值写入变量名2.var,若str2不存在则创建,若str1不存在则将str2设为None并提示错误。
使用示例
pvt.copy("str1","str2") # 复制str1里的值到str2
Project details
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
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 permanent_variable_tool-1.0.5.tar.gz.
File metadata
- Download URL: permanent_variable_tool-1.0.5.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d9babd6ac9a5c689085df3860d6964c5c5361bb9f5482eb3a06df0da5eddcad
|
|
| MD5 |
6747b95e93225764bb472f4e9a5c55f7
|
|
| BLAKE2b-256 |
dabac0496df3ef9cf05da5be19b171a2f287d3efa0388ff1db4f87ef0ed538e0
|
File details
Details for the file permanent_variable_tool-1.0.5-py3-none-any.whl.
File metadata
- Download URL: permanent_variable_tool-1.0.5-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc2892936fa2f4b0802b5273c246760a0f062a510e10e0561ae0802cbe961252
|
|
| MD5 |
ced09f638ccaee2018e1e56514b21919
|
|
| BLAKE2b-256 |
3f30c3cee9efb84011ec7da7204cb56bf68f1901930a0cf647fa9b5214763416
|