Python Descriptors

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ต.ค. 2024

ความคิดเห็น • 24

  • @MichaelHeyns
    @MichaelHeyns 4 ปีที่แล้ว +8

    Great talk! Thanks for sharing. Worth noting is PEP 487 that introduced a hook that calls ___set_name___ on all descriptors upon class creation, meaning descriptors now can have knowledge of the field names they are associated with.

    • @chesterVonWinchester
      @chesterVonWinchester 3 ปีที่แล้ว

      Cool, thanks. Also, usage examples here: docs.python.org/3/howto/descriptor.html#customized-names

  • @gena8414
    @gena8414 9 หลายเดือนก่อน

    I really like the way you model your explanations: and clearly define what level of abstractions you are dealing with. Quite clear, no space for ambiguities. I would lve to see a full OO course in Python from you.

  • @salkdjfasldkfjsdlk
    @salkdjfasldkfjsdlk 10 ปีที่แล้ว +13

    This talk makes me not want to write my own descriptors. Needs work to simplify it for daily users. GL

  • @alexd7466
    @alexd7466 ปีที่แล้ว

    Talking about Descriptors is a great way to make Java developers realize they don't really understand Python, @property and @classmethod.

  • @MasterSergius
    @MasterSergius 7 ปีที่แล้ว +2

    Probably, the best explanation I've ever seen!

  • @ko95
    @ko95 4 ปีที่แล้ว

    some notes from the lectures in @23:49
    Descriptors: A generic mechanism to create getters and setter that you can resuse.
    A descriptor encapulates attribute getting/setting logic in a reusable way. (what is a reusable way?)
    th-cam.com/video/81S01c9zytE/w-d-xo.html
    th-cam.com/video/81S01c9zytE/w-d-xo.html - In order for a descriptor to do its magic, it needs to be a class attribute, not an instance attribute.
    AFAIK Properties implements the descriptor protocol, properties provides an interface to instance attributes (properties intercept access to attributes). The descriptor protocol is tied to scoping and has a execution precedence ("7 simple rules")
    Cant really connect more dots than this right now...
    What is a descriptor ?
    How do i use it?
    When do i use it?
    Why do i use it?

  • @iamsantosh
    @iamsantosh 9 ปีที่แล้ว +5

    The Guy is genious man #simonFranklin and teaching style awesome

  • @novicesim3642
    @novicesim3642 5 ปีที่แล้ว +8

    Gosh.. my level of understanding on python doesnt reach the level where i could understand this video

    • @OttoFazzl
      @OttoFazzl 5 ปีที่แล้ว

      I can relate. A year ago I wouldn't understand it, too. Just keep working on it, and everything will make sense. Read more books like "Powerful Python" or "Python Cookbook", and you will understand it.

    • @Guinhulol
      @Guinhulol 4 ปีที่แล้ว

      Give yourself a tap in the back, not everybody made it this fair, I mean most Python dev they stick to the basic stuff

  • @VannaVolga
    @VannaVolga 4 ปีที่แล้ว

    For people watching this now: PEP 487 (Python 3.6) introduced a __set_name__ hook on the descriptor which is called upon class creation. This makes it possible to store values in the instance `__dict__` with this name. See www.python.org/dev/peps/pep-0487/.

  • @jonathanhexner
    @jonathanhexner 9 ปีที่แล้ว

    Excellent explanation of descriptors!

  • @mobilkonto__free__9726
    @mobilkonto__free__9726 5 ปีที่แล้ว +2

    Great professor

  • @mobilkonto__free__9726
    @mobilkonto__free__9726 5 ปีที่แล้ว +2

    Amazing man

  • @diodin8587
    @diodin8587 4 ปีที่แล้ว

    Didn't mention `__getattr__` and `__getattribute__`?

  • @shawnc7800
    @shawnc7800 6 ปีที่แล้ว

    Awesome video!Thanks very very much!

  • @muh_guts
    @muh_guts 3 ปีที่แล้ว

    man, basically you saved me

  • @ald7248
    @ald7248 7 ปีที่แล้ว +2

    I do not understand the praise for this talk. Raymond Hettinger's excellent "Descriptor HOWTO" is clearer in all respects and more comprehensive to boot.

  • @arkster00
    @arkster00 10 ปีที่แล้ว

    Awesome talk.

  • @kevinl7139
    @kevinl7139 6 ปีที่แล้ว +1

    this shit is way over my head

  • @robinarora3999
    @robinarora3999 ปีที่แล้ว

    And someone said python is easy!!