#specialmethodname — Public Fediverse posts
Live and recent posts from across the Fediverse tagged #specialmethodname, aggregated by home.social.
-
As with any convention, it depends somewhat on opinion. My take:
double-underscore is for Python-provided methods that you want to override, like __mul__ or __getitem__. Not for adding your own unrelated methods; if you want those to be "private", use single underscores.
Python may add new special methods in future, and if they collide with a dunder name you've used for your own method, you could get serious breakage.
-
As with any convention, it depends somewhat on opinion. My take:
double-underscore is for Python-provided methods that you want to override, like __mul__ or __getitem__. Not for adding your own unrelated methods; if you want those to be "private", use single underscores.
Python may add new special methods in future, and if they collide with a dunder name you've used for your own method, you could get serious breakage.