久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <small id='9YPDG'></small><noframes id='9YPDG'>

      <i id='9YPDG'><tr id='9YPDG'><dt id='9YPDG'><q id='9YPDG'><span id='9YPDG'><b id='9YPDG'><form id='9YPDG'><ins id='9YPDG'></ins><ul id='9YPDG'></ul><sub id='9YPDG'></sub></form><legend id='9YPDG'></legend><bdo id='9YPDG'><pre id='9YPDG'><center id='9YPDG'></center></pre></bdo></b><th id='9YPDG'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='9YPDG'><tfoot id='9YPDG'></tfoot><dl id='9YPDG'><fieldset id='9YPDG'></fieldset></dl></div>
      <tfoot id='9YPDG'></tfoot>

        • <bdo id='9YPDG'></bdo><ul id='9YPDG'></ul>
        <legend id='9YPDG'><style id='9YPDG'><dir id='9YPDG'><q id='9YPDG'></q></dir></style></legend>
      1. 為什么 __get__ 獲取所有者而 __set__ 和 __delete__ 不

        Why does __get__ take an owner while __set__ and __delete__ do not?(為什么 __get__ 獲取所有者而 __set__ 和 __delete__ 不獲取?)

          <tbody id='vcobb'></tbody>
          • <bdo id='vcobb'></bdo><ul id='vcobb'></ul>

            1. <tfoot id='vcobb'></tfoot>

            2. <legend id='vcobb'><style id='vcobb'><dir id='vcobb'><q id='vcobb'></q></dir></style></legend>
            3. <i id='vcobb'><tr id='vcobb'><dt id='vcobb'><q id='vcobb'><span id='vcobb'><b id='vcobb'><form id='vcobb'><ins id='vcobb'></ins><ul id='vcobb'></ul><sub id='vcobb'></sub></form><legend id='vcobb'></legend><bdo id='vcobb'><pre id='vcobb'><center id='vcobb'></center></pre></bdo></b><th id='vcobb'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='vcobb'><tfoot id='vcobb'></tfoot><dl id='vcobb'><fieldset id='vcobb'></fieldset></dl></div>
                • <small id='vcobb'></small><noframes id='vcobb'>

                  本文介紹了為什么 __get__ 獲取所有者而 __set__ 和 __delete__ 不獲取?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  來自 Python 數據模型文檔:p><塊引用>

                  object.__get__(self, instance, owner=None)

                  調用以獲取所有者類的屬性(類屬性訪問)或該類的實例(實例屬性訪問).可選的 owner 參數是所有者類,而 instance 是訪問屬性的實例,或者 None 訪問屬性時所有者.

                  此方法應返回計算的屬性值或引發 AttributeError 異常.

                  PEP 252 指定 __get__() 可以用一個或兩個參數調用.Python 自己的內置描述符支持此規范;但是,某些第三方工具可能具有需要兩個參數的描述符.Python 自己的 __getattribute__() 實現總是傳入兩個參數,無論它們是否需要.

                  object.__set__(self, instance, value)

                  調用以將所有者類的實例 instance 上的屬性設置為新值 value.

                  注意,添加 __set__()__delete__() 會將描述符的種類更改為數據描述符".有關詳細信息,請參閱調用描述符.

                  object.__delete__(self, instance)

                  調用來刪除所有者類的實例instance上的屬性.

                  為什么 __get__ 使用 owner__set____delete__ 沒有?

                  是不是意味著當一個描述符同時提供__get____set__時,

                  • 無論是屬于所有者類的實例還是屬于所有者類,我們都可以得到一個屬性,
                  • 我們可以設置和刪除屬于所有者類實例的屬性,但不能在屬于所有者類時設置和刪除?

                  我的問題實際上是這個的一部分.

                  解決方案

                  owner 主要用于獲取類本身的屬性,而不是實例.當您檢索實例的屬性時,owner 參數是多余的,因為它只是 type(instance).

                  __set__ 不適用于設置類本身的屬性,所以 owner 沒有用.

                  From the Python data model documentation:

                  object.__get__(self, instance, owner=None)

                  Called to get the attribute of the owner class (class attribute access) or of an instance of that class (instance attribute access). The optional owner argument is the owner class, while instance is the instance that the attribute was accessed through, or None when the attribute is accessed through the owner.

                  This method should return the computed attribute value or raise an AttributeError exception.

                  PEP 252 specifies that __get__() is callable with one or two arguments. Python’s own built-in descriptors support this specification; however, it is likely that some third-party tools have descriptors that require both arguments. Python’s own __getattribute__() implementation always passes in both arguments whether they are required or not.

                  object.__set__(self, instance, value)

                  Called to set the attribute on an instance instance of the owner class to a new value, value.

                  Note, adding __set__() or __delete__() changes the kind of descriptor to a "data descriptor". See Invoking Descriptors for more details.

                  object.__delete__(self, instance)

                  Called to delete the attribute on an instance instance of the owner class.

                  Why does __get__ take an owner while __set__ and __delete__ do not?

                  Does it mean that when a descriptor supplies both __get__ and __set__,

                  • we can get an attribute no matter whether it belongs to an instance of the owner class or to the owner class,
                  • we can set and delete an attribute when it belongs to an instance of the owner class but not when it belongs to the owner class?

                  My question is actually part of this one.

                  解決方案

                  owner mostly exists for getting the attribute on the class itself, rather than an instance. When you're retrieving the attribute on an instance, the owner argument is redundant, since it's just type(instance).

                  __set__ doesn't apply to setting the attribute on the class itself, so it has no use for owner.

                  這篇關于為什么 __get__ 獲取所有者而 __set__ 和 __delete__ 不獲取?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  python: Two modules and classes with the same name under different packages(python:不同包下同名的兩個模塊和類)
                  Configuring Python to use additional locations for site-packages(配置 Python 以使用站點包的其他位置)
                  How to structure python packages without repeating top level name for import(如何在不重復導入頂級名稱的情況下構造python包)
                  Install python packages on OpenShift(在 OpenShift 上安裝 python 包)
                  How to refresh sys.path?(如何刷新 sys.path?)
                  Distribute a Python package with a compiled dynamic shared library(分發帶有已編譯動態共享庫的 Python 包)
                  <tfoot id='YBYMw'></tfoot>

                    <small id='YBYMw'></small><noframes id='YBYMw'>

                      <tbody id='YBYMw'></tbody>
                        1. <i id='YBYMw'><tr id='YBYMw'><dt id='YBYMw'><q id='YBYMw'><span id='YBYMw'><b id='YBYMw'><form id='YBYMw'><ins id='YBYMw'></ins><ul id='YBYMw'></ul><sub id='YBYMw'></sub></form><legend id='YBYMw'></legend><bdo id='YBYMw'><pre id='YBYMw'><center id='YBYMw'></center></pre></bdo></b><th id='YBYMw'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='YBYMw'><tfoot id='YBYMw'></tfoot><dl id='YBYMw'><fieldset id='YBYMw'></fieldset></dl></div>
                            <bdo id='YBYMw'></bdo><ul id='YBYMw'></ul>
                          • <legend id='YBYMw'><style id='YBYMw'><dir id='YBYMw'><q id='YBYMw'></q></dir></style></legend>

                          • 主站蜘蛛池模板: 九九综合九九 | 91精品国产乱码久久久久久久久 | 少妇精品亚洲一区二区成人 | 国产乱一区二区三区视频 | 久草精品视频 | 久久成人精品视频 | 国产一区不卡 | 美女一级a毛片免费观看97 | 黄片毛片在线观看 | 国产成人一区二区 | 日韩视频在线播放 | 中文一区| 国产成人亚洲精品 | 99资源站 | 国产一区久久 | 天天爽综合网 | 国产福利免费视频 | 中文字幕视频在线 | 久久99深爱久久99精品 | 亚洲女人天堂成人av在线 | 激情久久久久 | 国产成人精品免费视频大全最热 | 中文字幕日韩在线 | 精品久久一 | 欧美九九 | 欧美福利影院 | 国产区精品视频 | 91av在线不卡| 国产一区二区三区四区区 | 久久久在线视频 | 成人在线视频网址 | 亚洲精品国产偷自在线观看 | 日韩三区| 五月综合激情婷婷 | 国产精品二区三区 | 成人免费高清 | 久久男人| 国产97人人超碰caoprom | 欧美一区二区三区大片 | 午夜电影网站 | 国产精品极品美女在线观看免费 |