@@ -16,7 +16,7 @@ Our `pyscript.ffi` offers the following utilities:
16
16
counterpart.
17
17
* ` ffi.create_proxy(def_or_lambda) ` proxies a generic Python function into a
18
18
JavaScript one, without destroying its reference right away.
19
- * ` ffi.is_none(reference) ` to check if a specific value is either ` None ` or ` JsNull `
19
+ * ` ffi.is_none(reference) ` to check if a specific value is either ` None ` or ` JsNull ` .
20
20
21
21
Should you require access to Pyodide or MicroPython's specific version of the
22
22
FFI you'll find them under the ` pyodide.ffi ` and ` micropython.ffi ` namespaces.
@@ -213,22 +213,24 @@ only in Pyodide can we then destroy such proxy:
213
213
214
214
## is_none
215
215
216
- Starting from * Pyodide* version ` 0.28 ` , there is a new * nullish* value in town that is
217
- meant to represent exactly the * JS * ` null ` value.
216
+ * Pyodide* version ` 0.28 ` onwards has introduced a new * nullish* value that
217
+ precisely represents JavaScript's ` null ` value.
218
218
219
- Previously, both ` null ` and ` undefined ` would have been converted into ` None `
220
- but some * API* behaves differently if one value is absent or explicitly ` null ` .
219
+ Previously, both JavaScript ` null ` and ` undefined ` would have been converted
220
+ into Python's ` None ` but, alas, some APIs behave differently if a value is
221
+ ` undefined ` or explicitly ` null ` .
221
222
222
- In * JSON* , ` null ` would also survive serialization while ` undefined ` would
223
- vanish. To preserve that distinction also in * Python* , the conversion
224
- between * JS* and * Python* now has a new ` pyodide.ffi.jsnull ` as showed in
223
+ For example, in * JSON* , ` null ` would survive serialization while ` undefined `
224
+ would vanish. To preserve that distinction in * Python* , the conversion
225
+ between * JS* and * Python* now has a new ` pyodide.ffi.jsnull ` as explained in
226
+ the
225
227
[ pyodide documentation] ( https://pyodide.org/en/stable/usage/type-conversions.html#javascript-to-python ) .
226
228
227
- In general, there should be no surprise but, specially when dealing with the * DOM *
228
- world, most utilities and methods would return ` null ` .
229
+ In general, there should be no surprises. But, especially when dealing with the
230
+ * DOM * world, most utilities and methods return ` null ` .
229
231
230
- To simplify and smooth-out this distinction, we decided to introduce ` is_null `
231
- as [ demoed live in here] ( https://pyscript.com/@agiammarchi/pyscript-ffi-is-none/latest?files=main.py ) :
232
+ To simplify and smooth-out this distinction, we decided to introduce ` is_null ` ,
233
+ as [ demoed here] ( https://pyscript.com/@agiammarchi/pyscript-ffi-is-none/latest?files=main.py ) :
232
234
233
235
``` html title="pyscript.ffi.is_none"
234
236
<!-- success in both Pyodide and MicroPython -->
@@ -243,7 +245,7 @@ as [demoed live in here](https://pyscript.com/@agiammarchi/pyscript-ffi-is-none/
243
245
print (js_null) # jsnull
244
246
print (js_null is None) # False
245
247
246
- # JsNull is still " falsy" as value
248
+ # JsNull is still a " falsy" value
247
249
if (js_null):
248
250
print (" this will not be shown" )
249
251
@@ -254,5 +256,6 @@ as [demoed live in here](https://pyscript.com/@agiammarchi/pyscript-ffi-is-none/
254
256
```
255
257
256
258
Please note that in * MicroPython* the method works the same but, as we try to
257
- reach features-parity among runtimes, it is suggested to use ` is_none(ref) `
258
- even if right now there is not such distinction between ` null ` and ` undefined ` .
259
+ reach feature-parity among runtimes, it is suggested to use ` is_none(ref) `
260
+ even if, right now, there is no such distinction between ` null ` and
261
+ ` undefined ` in MicroPython.
0 commit comments