Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any ideas about how to get rid of self? [closed]

Tags:

python

self

Is there anyway of making Python methods have access to the class fields/methods without using the self parameter?

It's really annoying having to write self. self. self. self. The code gets so ugly to the point I'm thinking of not using classes anymore purely for code aesthetics. I don't care about the risks or best practices. I just want not to see self anymore.

P.S. I know about the renaming possibility but it's not the point.

like image 764
Al Bundy Avatar asked Dec 26 '22 09:12

Al Bundy


1 Answers

This blog by Guido explains why it's here to stay: http://neopythonic.blogspot.co.uk/2008/10/why-explicit-self-has-to-stay.html

like image 58
Noel Evans Avatar answered Feb 08 '23 23:02

Noel Evans