File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,10 +10,17 @@ pip install nullsafe
1010
1111## Quick Start
1212
13+ Dummy Class
14+
15+ ``` python
16+ class Dummy :
17+ pass
18+ ```
19+
1320Normal Python code
1421
1522``` python
16- o = object ()
23+ o = Dummy ()
1724
1825try :
1926 value = o.inexistent
@@ -27,7 +34,7 @@ With nullsafe:
2734``` python
2835from nullsafe import undefined, _
2936
30- o = object ()
37+ o = Dummy ()
3138
3239value = _(o).inexistent
3340
@@ -92,7 +99,7 @@ There are various way to get a nullsafe proxied object.
9299Proxied object doing a possibly ` AttributeError ` access.
93100
94101``` python
95- o = SomeClass ()
102+ o = Dummy ()
96103
97104# o.inexistent
98105assert _(o).inexistent is undefined
@@ -114,7 +121,7 @@ assert _(_(o).maybe).inexistent.nested is undefined
114121Proxied object doing a possibly ` KeyError ` access.
115122
116123``` python
117- o = SomeClass () # dict works too !
124+ o = Dummy () # dict works too !
118125
119126# o.inexistent
120127assert _(o)[" inexistent" ] is undefined
@@ -138,7 +145,7 @@ Possibly `None` or `undefined` object doing possibly `AttributeError` or `KeyErr
138145Note: This only works if the seeking value is accessible, see [ limitations] ( #post-evaluation )
139146
140147``` python
141- o = SomeClass () # dict works too !
148+ o = Dummy () # dict works too !
142149o.nay = None
143150
144151# o.nay?.inexistent
@@ -151,7 +158,7 @@ assert _(o.nay).inexistent.nested is undefined
151158```
152159
153160``` python
154- o = SomeClass () # dict works too !
161+ o = Dummy () # dict works too !
155162o[" nay" ] = None
156163
157164# o.nay?.inexistent
You can’t perform that action at this time.
0 commit comments