Skip to content

Commit 2332f4f

Browse files
committed
Minor edits.
1 parent 69e85e3 commit 2332f4f

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

docs/user-guide/ffi.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Our `pyscript.ffi` offers the following utilities:
1616
counterpart.
1717
* `ffi.create_proxy(def_or_lambda)` proxies a generic Python function into a
1818
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`.
2020

2121
Should you require access to Pyodide or MicroPython's specific version of the
2222
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:
213213

214214
## is_none
215215

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.
218218

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`.
221222

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
225227
[pyodide documentation](https://pyodide.org/en/stable/usage/type-conversions.html#javascript-to-python).
226228

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`.
229231

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):
232234

233235
```html title="pyscript.ffi.is_none"
234236
<!-- success in both Pyodide and MicroPython -->
@@ -243,7 +245,7 @@ as [demoed live in here](https://pyscript.com/@agiammarchi/pyscript-ffi-is-none/
243245
print(js_null) # jsnull
244246
print(js_null is None) # False
245247
246-
# JsNull is still "falsy" as value
248+
# JsNull is still a "falsy" value
247249
if (js_null):
248250
print("this will not be shown")
249251
@@ -254,5 +256,6 @@ as [demoed live in here](https://pyscript.com/@agiammarchi/pyscript-ffi-is-none/
254256
```
255257

256258
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

Comments
 (0)