In most object-oriented programming languages, we can refer to the newly created object and its methods with `this`; ‘this’ is a special keyword in many programming languages. It is a keyword that references the current object. This allows us to write class methods that make modifications to an object. Without it, we would not be able to make changes to the object internally. Here’s an example:
this keyword to update the name property at the name of the code as well. Python shows a similar pattern with only one or two fundamental changes.
In Python, `this` is replaced with a new keyword `self`. They fundamentally do the same thing. The only difference is the spelling of the keyword. Take a look at this example:
Advice For Any Language
My advice to you is to not just learn a programming language, but also understand the paradigm it belongs to; understanding a paradigm helps you gain clarity on different ways to program. That way you can spot the patterns across languages; programming languages come and go, but the way people program is here to stay. With that, key tool, you can get up and running in a language very quickly.Stay tuned for more posts on Python and programming!