Albbi@piefed.ca to Programmer Humor@programming.devEnglish · 2 days agoObject oriented programming in Python be like:media.piefed.caimagemessage-square47fedilinkarrow-up1478arrow-down113
arrow-up1465arrow-down1imageObject oriented programming in Python be like:media.piefed.caAlbbi@piefed.ca to Programmer Humor@programming.devEnglish · 2 days agomessage-square47fedilink
minus-squareEager Eagle@lemmy.worldlinkfedilinkEnglisharrow-up82·edit-22 days agonah, I’m never complaining about self in Python after having tried the this and that nonsense in JS. oh, you’re using a named function instead of an arrow fn? Guess what, this is not what it used to be anymore.
minus-squareunalivejoy@lemmy.ziplinkfedilinkarrow-up21·2 days agoOh, you assigned a method to a variable before calling it? Congratulations, this is now undefined.
minus-squarepinball_wizard@lemmy.ziplinkfedilinkarrow-up4·1 day agoYes. There’s no telling what this is. this could be anything. We tried to keep track of this, but no one knows when this will change.
minus-squareunalivejoy@lemmy.ziplinkfedilinkarrow-up7·1 day agoI used to be with this, but then they changed what this was. Now what I’m with isn’t this, and what’s this seems weird and scary to me. This’ll happen to you!
minus-squaretheit8514@lemmy.worldlinkfedilinkarrow-up41·2 days agoOnly if you define it. const that = this
minus-squaremesa@piefed.sociallinkfedilinkEnglisharrow-up14·2 days agoI remember that a long time ago. Oh god
minus-squareAurenkin@sh.itjust.workslinkfedilinkarrow-up6·2 days agoI remember this too… what a nightmare.
minus-squareEager Eagle@lemmy.worldlinkfedilinkEnglisharrow-up30·edit-22 days agoit’s common practice as a workaround to save this when changing contexts, since this may change under you, in callbacks and such
minus-squaredufkm@lemmy.worldlinkfedilinkEnglisharrow-up5arrow-down1·2 days agoAs a non-programmer who’s occasionally dabbled with wxPython, I’ve entangled myself with self.parent.parent and their childs/siblings more than once. At that stage I know my project is done.
nah, I’m never complaining about
self
in Python after having tried thethis
andthat
nonsense in JS.oh, you’re using a named function instead of an arrow fn? Guess what,
this
is not what it used to be anymore.Oh, you assigned a method to a variable before calling it? Congratulations,
this
is nowundefined
.Yes. There’s no telling what
this
is.this
could be anything. We tried to keep track ofthis
, but no one knows whenthis
will change.I used to be with
this
, but then they changed whatthis
was.Now what I’m with isn’t
this
, and what’sthis
seems weird and scary to me.This’ll happen to you!
Wait there’s a “that”???
Only if you define it.
const that = this
I remember that a long time ago. Oh god
I remember this too… what a nightmare.
it’s common practice as a workaround to save
this
when changing contexts, sincethis
may change under you, in callbacks and suchKotlin:
this@outerFunction.bla
Yeah totally agree.
As a non-programmer who’s occasionally dabbled with wxPython, I’ve entangled myself with self.parent.parent and their childs/siblings more than once. At that stage I know my project is done.