Python Forum

Full Version: self vs some other name
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
is there anyone that regularly uses other names or one other name, in place of self, when coding methods of a class?
why?
The only acceptable time to use something else is for methods decorated as @classmethod in which case you should use cls instead of self.

Yes, these are all conventions, but if you expect anyone else to read your code you should follow them.
* Skaperen has learned how to obfuscate his python code
(Feb-23-2017, 09:56 AM)Skaperen Wrote: [ -> ]* Skaperen has learned how to obfuscate his python code
I think you have manage to do that before too Wink
(Feb-23-2017, 10:53 AM)snippsat Wrote: [ -> ]
(Feb-23-2017, 09:56 AM)Skaperen Wrote: [ -> ]* Skaperen has learned how to obfuscate his python code
I think you have manage to do that before too Wink

but that was the original poorly written code.
I've seen people use "this" before, for obvious reasons. It's annoying, please don't do that.
(Mar-27-2017, 06:42 PM)nilamo Wrote: [ -> ]I've seen people use "this" before, for obvious reasons.  It's annoying, please don't do that.

It's kind of funny. At least you know who to ask if you have questions for some other programming language.  Smile