Hello, i am fairly new to python programming (learning the basics). As of now i am learning about objects, decorators etc, and how they work.
I attached a file, a picture to show you what my problem is. I do not understand the use of the 'set_position'-method in the second code, to the right.
I summarized my understanding of the codes with a comment in each one. I attached the .py-files as well.
Feel free to to give some input, appreciate any answers.
If you wonder why i make the code hard to read with different reference-variables and so forth, it is because i'm just trying to see every aspect of what is happening in the code . Sorry about that.
//Edit
In fact, i now realized that i can remove 'set_position' in the first code aswell (the one on the left), and there is no difference. In terms of output that is.
So the 'set_position' becomes irrelevant?
Unless i add a parameter like this:
def set_position(T, y):
T.f["position"] = y
T.f["ASDFGH"] = y
and then in the main-function i can now create a new keyword-argument:
Yerry.set_position("Drag")
Yerry = D(Drag = "run")
But i still have to make a method in the class so i can call it?
Now i am really confused, i have definitely missed out on something.
I attached a file, a picture to show you what my problem is. I do not understand the use of the 'set_position'-method in the second code, to the right.
I summarized my understanding of the codes with a comment in each one. I attached the .py-files as well.
Feel free to to give some input, appreciate any answers.
If you wonder why i make the code hard to read with different reference-variables and so forth, it is because i'm just trying to see every aspect of what is happening in the code . Sorry about that.
//Edit
In fact, i now realized that i can remove 'set_position' in the first code aswell (the one on the left), and there is no difference. In terms of output that is.
So the 'set_position' becomes irrelevant?
Unless i add a parameter like this:
def set_position(T, y):
T.f["position"] = y
T.f["ASDFGH"] = y
and then in the main-function i can now create a new keyword-argument:
Yerry.set_position("Drag")
Yerry = D(Drag = "run")
But i still have to make a method in the class so i can call it?
Now i am really confused, i have definitely missed out on something.
Attachments
-
903.2 KB Views: 6
-
953 bytes Views: 3
-
958 bytes Views: 2
Last edited: