From 6c06c65bf4fabcadfccbfa08844fec69fc9fb52e Mon Sep 17 00:00:00 2001 From: TheArtur128 <88573504+TheArtur128@users.noreply.github.com> Date: Mon, 7 Aug 2023 21:16:52 +0700 Subject: [PATCH] doc(`README.md`): correction --- README.md | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a28f422..5c8c307 100644 --- a/README.md +++ b/README.md @@ -1290,12 +1290,10 @@ Create from others class Alpha: a = 1 - class Beta: def __init__(self, b): self.b = b - obj.of(Alpha, Beta(2)) ``` ``` @@ -1307,10 +1305,10 @@ Create object templates ```py User = temp(name=str, age=int) # -User("Oliver", 24) # +User("Oliver", 24) ``` ``` - + ```
@@ -1328,7 +1326,10 @@ User("Oliver", 24) # > (temp(name=str) & obj(__call__=print))("Oliver")(1, 2, 3, sep=' -> ') # 1 -> 2 -> 3 > > temp() == obj() -> +> ``` + +> `isinstance` checks for empty fields as their presence. +> ```py > isinstance(obj(name="Oliver", age=24), temp(name=str)) > isinstance(obj(name="Oliver", age=24), temp(name=str) & obj(age=24)) > not isinstance(obj(name="Oliver", age=24), temp(name=str) & obj(age=26)) @@ -1350,11 +1351,14 @@ User("Oliver", 24) # > > @temp.of > @dataclass -> class Struct: # +> class Struct: > a: int > b: int = 2 > c: int = field(default_factory=lambda: 4) > ``` +> ``` +> +> ```
@@ -1385,7 +1389,7 @@ sculpture.number == original.a == 16 ```py ... -proxy_of = sculpture_of(number=o.a / 2, value=property(v.a, v.a.mset(w * 2))) +proxy_of = sculpture_of(number=v.a / 2, value=property(v.a, v.a.mset(w * 2))) sculpture = proxy_of(original) @@ -1443,8 +1447,8 @@ with_a = WithA(None) from_(obj(a=1, b=2), with_a) -type(with_a) # with_a.__dict__ # {'a': 1, 'b': 2} +type(with_a) # ``` Use optional attributes