#๐Ÿ”’ property class

61 messages ยท Page 1 of 1 (latest)

summer marsh
#

i want to learn the pdf..
i will send screenshots one by one

fringe ravenBOT
#

@summer marsh

Python help channel opened

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.

pseudo pewter
#

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?

summer marsh
#

i get that first attribute...is making the function calls more readable

pseudo pewter
#

are you using this PDF in a course, or on your own?

summer marsh
#

and the fget and fset is in init function

summer marsh
pseudo pewter
supple path
#

Are you using this PDF in a course or on your own?

summer marsh
#

in a course

#

i am using this pdf froma course

pseudo pewter
summer marsh
#

no, it is after that

#

but in same lecture

pseudo pewter
#

and you are required to use these slides to learn?

summer marsh
#

yes

#

it would we a lot better if i learned tis pdg

#

pdf

pseudo pewter
#

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?

summer marsh
pseudo pewter
#

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 ...."

summer marsh
summer marsh
pseudo pewter
#

I think if you understand the effect of @property, you don't need to understand the underlying mechanisms.

summer marsh
#

in the last language.setter is confusing me

pseudo pewter
#

ok: @language.setter will be run when you do my_object.language = "spanish"

summer marsh
#

wait do we use these interchangeably or one is the twin of one another

pseudo pewter
#

used which interchangeably?

summer marsh
#

@language.setter and my_object.language = "spanish"

pseudo pewter
summer marsh
#

and what it will run

pseudo pewter
summer marsh
#

uh..ohk

#

one more thing...does decorators works only in classes?

pseudo pewter
#

no, they work outside of classes also, but @property is meant for inside classes.

summer marsh
#

and should i learn my educators content or not?

pseudo pewter
summer marsh
#

okay..

tall marsh
#

though if there are going to be tests, those tests are likely on the taught content

pseudo pewter
#

that could be a factor to consider, yes

summer marsh
pseudo pewter
#

idk, and it doesn't matter, since our situations are different.

summer marsh
#

ok nvm...i won't take much of your time

pseudo pewter
#

it's ok

summer marsh
#

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

olive phoenix
# summer marsh and what it will run

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)

pseudo pewter
#

TIL that the setter method needs to be called field.

olive phoenix
pseudo pewter
olive phoenix
#

yeah but field would also be confusing

pseudo pewter
olive phoenix
#

indeed, the less confusing (from that perspective) version would involve not using @ but thats not how things are written in practice

pseudo pewter
#

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.

fringe ravenBOT
#
Python help channel closed for inactivity

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.