DEV Community

Discussion on: JavaScript is almost pythonic

Collapse
 
r0f1 profile image
Florian Rohrer

To add to the Getter & Setter examples: You can use this in Python instead of self. It is just a convention, that people refer to the current instance as self. Also, instead of sqrt in both languages, you can write **0.5. With both modifications, that codes look even more similar.

About the classes example: They might look similar, but they are not. __init__ is not a constructor. __init__ is an initializer. The constructor in Python is called __new__. Also, usually you override __repr__ to get a representation of the object instead of __str__.