add some docs

This commit is contained in:
blueloveTH 2024-04-14 00:17:02 +08:00
parent 7a145b6c02
commit a54c7e4b03
2 changed files with 28 additions and 0 deletions

View File

@ -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.
!!!

View File

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