mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
add some docs
This commit is contained in:
parent
7a145b6c02
commit
a54c7e4b03
@ -41,3 +41,30 @@ The easiest way to test a feature is to [try it on your browser](https://pocketp
|
|||||||
10. `%`, `&`, `//`, `^` and `|` for `int` behave the same as C, not python.
|
10. `%`, `&`, `//`, `^` and `|` for `int` behave the same as C, not python.
|
||||||
11. `str.split` and `str.splitlines` will remove all empty entries.
|
11. `str.split` and `str.splitlines` will remove all empty entries.
|
||||||
12. `__getattr__`, `__setattr__` and `__delattr__` can only be set in cpp.
|
12. `__getattr__`, `__setattr__` and `__delattr__` can only be set in cpp.
|
||||||
|
|
||||||
|
### Make `next()` compatible with cpython
|
||||||
|
|
||||||
|
You can use the following code to make `next()` compatible with cpython temporarily.
|
||||||
|
|
||||||
|
```python
|
||||||
|
import builtins
|
||||||
|
|
||||||
|
def next(obj):
|
||||||
|
res = builtins.next(obj)
|
||||||
|
if res is StopIteration:
|
||||||
|
raise StopIteration
|
||||||
|
return res
|
||||||
|
|
||||||
|
a = iter([1])
|
||||||
|
assert next(a) == 1
|
||||||
|
|
||||||
|
try:
|
||||||
|
next(a)
|
||||||
|
exit(1)
|
||||||
|
except StopIteration:
|
||||||
|
pass
|
||||||
|
```
|
||||||
|
|
||||||
|
!!!
|
||||||
|
Do not change `builtins.next`. It will break some internal functions which rely on `StopIteration` as return value.
|
||||||
|
!!!
|
@ -5,3 +5,4 @@ label: itertools
|
|||||||
|
|
||||||
### `itertools.zip_longest(a, b)`
|
### `itertools.zip_longest(a, b)`
|
||||||
|
|
||||||
|
Returns an iterator that aggregates elements from the input iterables. If the input iterables are of different lengths, missing values are filled-in with `None`.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user