Language features
pocketpy supports the core Python constructs used in application scripts. The compatibility guide explains where their behavior differs from CPython; support for a construct does not imply support for every Python variant of it.
Functions, data, and iteration
def scaled(values, factor=2):
for value in values:
yield value * factor
scores = [3, 5, 8]
assert list(scaled(scores, factor=3)) == [9, 15, 24]
assert {score: score * score for score in scores} == {3: 9, 5: 25, 8: 64}
Classes and properties
class Player:
def __init__(self, name):
self.name = name
self.score = 0
@property
def rank(self):
return self.score // 100
player = Player('Ada')
player.score = 250
assert player.rank == 2
Special methods
These are the principal special methods recognized by the runtime. Define them on your own types; do not modify built-in types.
In-place hooks such as __iadd__ and reflected bitwise hooks such as
__rand__ are not supported. Attributes such as __name__ and
__all__ are metadata, rather than callable special methods.
The complete runtime name list is in magics.h.