4 ms·
Manually capturing free variables via: def __init__(self, x, y, ..): self.x = x self.y = y Is so tedious and DRY-violating.
by Peaker 14y ago
Manually capturing free variables via:
def __init__(self, x, y, ..):
self.x = x
self.y = y
Is so tedious and DRY-violating.
- lmm 14y agoThis is true. I'd prefer scala-style constructor syntax - though I'm not sure how you could retain python's wonderful symmetry between constructors and methods, and the distinction between allocation and initialization.
- Peaker 14y agoI don't know Scala, but the Erights language does something like (pseudo-syntax): def Circle(center, radius): circumference = 2 * pi * radius return object: to getCircumference(): return circumference to ... The "self" is the lexical scope. Simple and more effective than Python's method, IMO.