Hacker News new | past | comments | ask | show | jobs | submit login

Manually capturing free variables via:

  def __init__(self, x, y, ..):
    self.x = x
    self.y = y
Is so tedious and DRY-violating.



This 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.


I 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.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: