mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-24 13:30:18 +00:00
2.5 KiB
2.5 KiB
| icon | title | order |
|---|---|---|
| dot | Basic Features | 100 |
Check this Cheatsheet for a quick overview of the supported features.
The following table shows the basic features of pkpy with respect to cpython.
The features marked with YES are supported, and the features marked with NO are not supported.
| Name | Example | Supported |
|---|---|---|
| If Else | if..else..elif |
YES |
| Loop | for/while/break/continue |
YES |
| Function | def f(x,*args,y=1): |
YES |
| Subclass | class A(B): |
YES |
| List | [1, 2, 'a'] |
YES |
| ListComp | [i for i in range(5)] |
YES |
| Slice | a[1:2], a[:2], a[1:] |
YES |
| Tuple | (1, 2, 'a') |
YES |
| Dict | {'a': 1, 'b': 2} |
YES |
| F-String | f'value is {x}' |
YES |
| Unpacking | a, b = 1, 2 |
YES |
| Star Unpacking | a, *b = [1, 2, 3] |
YES |
| Exception | raise/try..catch |
YES |
| Dynamic Code | eval()/exec() |
YES |
| Reflection | hasattr()/getattr()/setattr() |
YES |
| Import | import/from..import |
YES |
| Context Block | with <expr> as <id>: |
YES |
| Type Annotation | def f(a:int, b:float=1) |
YES |
| Generator | yield i |
YES |
| Decorator | @cache |
YES |
Supported magic methods
Unary operators
__repr____str____hash____len____iter____next____json____neg____bool__(unused)
Logical operators
__eq____lt____le____gt____ge____contains__
Binary operators
__add____radd____sub____rsub____mul____rmul____truediv____floordiv____mod____pow____matmul____lshift____rshift____and____or____xor____invert__
Indexer
__getitem____setitem____delitem__
Specials
__new____init____call____divmod____enter____exit____name____all__