0
How do I retrieve the "this" value in python like the "prototype" method in JavaScript?
5 Respuestas
+ 1
Your question is unclear. prototype is not a method and it isn't used to retrieve the "this" value.
Well. In python there's no "this" but something called "self" is used instead:
https://www.sololearn.com/learn/Python/2467/
Tutorial on self:
https://code.sololearn.com/ce664AekBveN/?ref=app
+ 1
Thanks for clarifying.
It's not possible to modify python classes that way.
The closest approach I can think is extending the built-in class but that's far from Javascript prototypes:
https://code.sololearn.com/c3Q55kMTR4C5/?ref=app
You can't force a language to behave as other because their features and design are different.
+ 1
I'm interested in the results of your research. I don't understand what you mean with "if join can do it maybe there's a way" tho, but keep me posted.
0
For example in JavaScript I would write String.prototype.reverse=function(){for(i=this.length;abc.length<=this.length-1;i--){abc+=this[i-1]};return(abc)}; and use it as "reverse this string".reverse()
0
Thanks man I'll do some more research i figured if join can do it maybe there's a way.