|
|
@@ -30,40 +30,13 @@ The easiest way to test a feature is to [try it on your browser](https://pocketp
|
|
|
## Different behaviors
|
|
|
|
|
|
1. positional and keyword arguments are strictly evaluated.
|
|
|
-2. When a generator is exhausted, `StopIteration` is returned instead of raised.
|
|
|
-3. `++i` and `--j` is an increment/decrement statement, not an expression.
|
|
|
-4. `int` does not derive from `bool`.
|
|
|
-5. `int` is 64-bit. You can use `long` type explicitly for arbitrary sized integers.
|
|
|
-6. `__ne__` is not required. Define `__eq__` is enough.
|
|
|
-7. Raw string cannot have boundary quotes in it, even escaped. See [#55](https://github.com/pocketpy/pocketpy/issues/55).
|
|
|
-8. In a starred unpacked assignment, e.g. `a, b, *c = x`, the starred variable can only be presented in the last position. `a, *b, c = x` is not supported.
|
|
|
-9. A `Tab` is equivalent to 4 spaces. You can mix `Tab` and spaces in indentation, but it is not recommended.
|
|
|
-10. `%`, `&`, `//`, `^` and `|` for `int` behave the same as C, not python.
|
|
|
-11. `str.split` and `str.splitlines` will remove all empty entries.
|
|
|
-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)
|
|
|
-except StopIteration:
|
|
|
- print("a is exhausted")
|
|
|
-```
|
|
|
-
|
|
|
-!!!
|
|
|
-Do not change `builtins.next`. It will break internal functions which rely on `StopIteration` as return value.
|
|
|
-!!!
|
|
|
+2. `++i` and `--j` is an increment/decrement statement, not an expression.
|
|
|
+3. `int` does not derive from `bool`.
|
|
|
+4. `int` is 64-bit. You can use `long` type explicitly for arbitrary sized integers.
|
|
|
+5. `__ne__` is not required. Define `__eq__` is enough.
|
|
|
+6. Raw string cannot have boundary quotes in it, even escaped. See [#55](https://github.com/pocketpy/pocketpy/issues/55).
|
|
|
+7. In a starred unpacked assignment, e.g. `a, b, *c = x`, the starred variable can only be presented in the last position. `a, *b, c = x` is not supported.
|
|
|
+8. A `Tab` is equivalent to 4 spaces. You can mix `Tab` and spaces in indentation, but it is not recommended.
|
|
|
+9. `%`, `&`, `//`, `^` and `|` for `int` behave the same as C, not python.
|
|
|
+10. `str.split` and `str.splitlines` will remove all empty entries.
|
|
|
+11. `__getattr__`, `__setattr__` and `__delattr__` can only be set in cpp.
|