13 ms·
> Are there psychotic devs out there who call it something other than `self`? Yuck! I have, under duress. It was a result of using syntactic sugar wrapping a
by klyrs 6y ago
> Are there psychotic devs out there who call it something other than `self`? Yuck!
I have, under duress. It was a result of using syntactic sugar wrapping a PHP website to make a Python API; it was convenient to pass form variables into a generic handler method of a class. The problem? The website, fully outside of my control, had a page which had an input named "self" which resulted in two values for that argument. Rather than refactor the class and dozens of scripts that depended on it, I renamed 'self' to 's_lf' in that one function and called it a day.
Also, python has class methods. The convention is to use 'cls' in that context, to avoid confusing the parameter (a class) with an instance of that class.
- GeorgeTirebiter 6y agofor my own code, I use 'me' instead of 'self'. Just makes more sense to me; e.g. me.variable that is, the one referenced right here ('me') is being referenced, not from anywhere else. It's also shorter; and I think more descriptive. But that's just me.
- omaranto 6y agome.variable sounds Irish to me, at least compared to my.variable.
- thewakalix 6y agoAnd my.variable sounds Perlish.
- KMag 6y agoThat's because Perl was intended (Larry Wall was trained as a Linguist) to somewhat mimic natural English.
- lordgrenville 6y agoThat's a fascinating tidbit. You wouldn't exactly guess it from reading Perl.
- athms 6y ago>Larry Wall was trained as a Linguist Having an undergraduate degree doesn't make somebody a linguist. Let me know when he has contributed to the field through scholarly work. Doing Bible translations doesn't count.
- randompwd 6y ago> me.variable sounds Irish to me Only if you're used to the derogatory, clichéd "American TV" version of Irish.