2 ms·
I dont think `class` as a module keyword, in python, sucks. It just requires learning being open to python as python. Eg., class EG: NORTH, SOUTH,
by mjburgess 4y ago
I dont think `class` as a module keyword, in python, sucks. It just requires learning being open to python as python.
Eg.,
class EG:
NORTH, SOUTH, EAST, WEST = 1, 2, 3, 4
def move(a, b):
return a-b
EG.move(EG.NORTH, EG.WEST)
etc.
- zelphirkalt 4y agoThat would be a case for an enumeration, not a plain class. This usage would make me think: "And where does it get instantiated?" It is a fake class and this usage should be avoided.
- mjburgess 4y agopython -- syntax doesnt just correspond to one idea, the class keyword has a semantics entirely independent of an OO interpretation the whole point of design patterns is, exactly, to reuse "class etc." syntax for essentially non-OO purposes