Python Forum
self vs some other name - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: self vs some other name (/thread-2154.html)



self vs some other name - Skaperen - Feb-23-2017

is there anyone that regularly uses other names or one other name, in place of self, when coding methods of a class?


RE: self vs some other name - Larz60+ - Feb-23-2017

why?


RE: self vs some other name - Mekire - Feb-23-2017

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.


RE: self vs some other name - Skaperen - Feb-23-2017

* Skaperen has learned how to obfuscate his python code


RE: self vs some other name - snippsat - Feb-23-2017

(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


RE: self vs some other name - Skaperen - Feb-24-2017

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


RE: self vs some other name - nilamo - Mar-27-2017

I've seen people use "this" before, for obvious reasons. It's annoying, please don't do that.


RE: self vs some other name - wavic - Mar-27-2017

(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