Files3 Python Object Management
- English Version
- Intallation
- Quick Start
- Advanced
- Notice
- Cmd Command
- Last
- Chinese Version
- Intallation
- Quick Start
- Advanced
- Cmd Command
- Last
Installation
pip install files3
# After installation, you can use the command in cmd:
f3assoc .inst
to associate the '.inst' file with the 'f3open' program.
Quick Start
from files3 import files
f = files()
f.set('a', 1)
f.has('a')
print(f.get('a'))
f.delete('a')
files(dir:str="", type:str=".inst")
Advanced
from files3 import files
f = files()
f.a = 1
print(f.a)
del f.a
'a' in f
f.c = 1
f['c', 'data'] = [1, 2, 3, 4, 5]
print(f.list('c'))
del f['c']
f[('a', 'b')] = [1, 2]
print(f.a, f.b, f['a'], f['b'])
print(f[:])
print(f[lambda x: x == 'a'])
print(f[re.compile('a')])
del f[...]
fhash = f.hash('a')
f.retytpe('.newtype', 'a', 'b', ...)
f.retytpe('C:/mycode/code.py', 'a', 'b', ...)
Notice
There are some special case that you can't save:
- f3bool object and files object (alias Files, F3Shell)
- Actively refuse to serialize objects (such objects will actively throw errors when attempting to serialize)
- cases not supported by pickle (such as module, lambda, local function/class (that is nested inside other functions and classes))
Cmd Command
f3 [name] [type] -d [dir] # open a files3 object
f3open [fpath] # open a files3 object
f3assoc [type] # associate the '.type' file with the 'f3open' program
Last
It's really convinent but, because pickle is not safe, so mayn't use it to load the file you don't trust. However, if you do not care about it like me, you can use it to bring you a good programming experience.
安装files3
pip install files3
# 安装后,可以在cmd中使用命令:
f3assoc .inst
将'.inst'文件关联到'f3open'程序。
快速开始
from files3 import files
f = files()
f.set('a', 1)
f.has('a')
print(f.get('a'))
f.delete('a')
files(dir:str="", type:str=".inst")
高级用法
from files3 import files
f = files()
f.a = 1
print(f.a)
del f.a
'a' in f
f.c = 1
f['c', 'data'] = [1, 2, 3, 4, 5]
print(f.list('c'))
del f['c']
f[('a', 'b')] = [1, 2]
print(f.a, f.b, f['a'], f['b'])
print(f[:])
print(f[lambda x: x == 'a'])
print(f[re.compile('a')])
del f[...]
fhash = f.hash('a')
f.retytpe('.newtype', 'a', 'b', ...)
f.retytpe('C:/mycode/code.py', 'a', 'b', ...)
注意
有一些特殊情况不能保存:
- f3bool对象和files对象(别名Files, F3Shell)
- 主动拒绝序列化的对象(例如此类对象在试图序列化时会主动抛出error)
- pickle不支持的情况(例如 module,lambda,local function/class (那种嵌套在其他函数和class内部的))
Cmd命令
f3 [name] [type] -d [dir] # 打开一个files3对象
f3open [fpath] # 打开一个files3对象
f3assoc [type] # 将'.type'文件关联到'f3open'程序
最后
这确实很方便,但是由于pickle不安全,因此可能不要使用它来加载您不信任的文件。 但是,如果您不像我一样不怎么关心它,那么可以使用它为您带来良好的编程体验。