#๐ property class
61 messages ยท Page 1 of 1 (latest)
@summer marsh
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
fwiw, I would not explain it this way. Are you using this PDF in a class, or on your own?
and: what specifically on this slide is confusing you?
i get that first attribute...is making the function calls more readable
are you using this PDF in a course, or on your own?
and the fget and fset is in init function
using a pdf
on your own or in a course. Please try to fully answer our questions.
Are you using this PDF in a course or on your own?
is there a slide that talks about @property before this slide?
and you are required to use these slides to learn?
I think this slide is terrible, and teaches trivia that is not important to know. I am sorry that you have to use it.
can you show us the next slide?
I don't understand why people teach this way. Can you show us the next slide?
to me, this is like, "Here's how you drive a car: the engine has pistons ...."
i was enjoying the lectures in the beginning..but i also thought that i have discord if i get stuck somehwere
I think if you understand the effect of @property, you don't need to understand the underlying mechanisms.
i somehow grasped thwhat @property does
in the last language.setter is confusing me
ok: @language.setter will be run when you do my_object.language = "spanish"
wait do we use these interchangeably or one is the twin of one another
used which interchangeably?
@language.setter and my_object.language = "spanish"
they aren't interchangeable. my_obj.language = "spanish" will run the method you decorated with @language.setter
and what it will run
you should try writing some sample code and playing with it.
no, they work outside of classes also, but @property is meant for inside classes.
and should i learn my educators content or not?
you have to decide if you need to follow the course materials
okay..
though if there are going to be tests, those tests are likely on the taught content
that could be a factor to consider, yes
how did you learn OOP @pseudo pewter
idk, and it doesn't matter, since our situations are different.
ok nvm...i won't take much of your time
it's ok
i have nothing to say..i am still confused..but i think that is from my business...you all did well in understanding my situation
the_language_setter_function(my_obj, "spanish") where the_language_setter_function is the def language written with @language.setter
in general if you have
@field.setter
def field(self, new_value): # lets refer to this function as field_setter
...
in some class Class,
then when you have an instance of Class, lets say, my_object, then when you do my_object.field = thing it will call field_setter(my_object, thing)
(you need to fix the name of the method)
TIL that the setter method needs to be called field.
yeah because it will reassign a new property rather than mutating the old one
right, so "field_setter" is confusing in your explanation
yeah but field would also be confusing
it's all confusing!
indeed, the less confusing (from that perspective) version would involve not using @ but thats not how things are written in practice
unless the goal is to understand the effect of the decorator on the class API, which I think is the first thing to understand.
but now we are into the debate of how best to teach decorators, and that's where half the confusion always comes from.
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.