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

    • <bdo id='NQK1P'></bdo><ul id='NQK1P'></ul>
    <tfoot id='NQK1P'></tfoot>

    1. <legend id='NQK1P'><style id='NQK1P'><dir id='NQK1P'><q id='NQK1P'></q></dir></style></legend>

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

      1. <small id='NQK1P'></small><noframes id='NQK1P'>

        如何使 Python/Sphinx 文檔對象屬性僅在 __init__ 中聲

        How can I make Python/Sphinx document object attributes only declared in __init__?(如何使 Python/Sphinx 文檔對象屬性僅在 __init__ 中聲明?)

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

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

                <bdo id='nAfEA'></bdo><ul id='nAfEA'></ul>
                <legend id='nAfEA'><style id='nAfEA'><dir id='nAfEA'><q id='nAfEA'></q></dir></style></legend>
                • 本文介紹了如何使 Python/Sphinx 文檔對象屬性僅在 __init__ 中聲明?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有帶有對象屬性的 Python 類,這些對象屬性僅在運行構造函數時聲明,如下所示:

                  I have Python classes with object attributes which are only declared as part of running the constructor, like so:

                  class Foo(object):
                      def __init__(self, base):
                          self.basepath = base
                  
                          temp = []
                          for run in os.listdir(self.basepath):
                              if self.foo(run):
                                  temp.append(run)
                          self.availableruns = tuple(sorted(temp))
                  

                  如果我現在使用 help(Foo) 或嘗試在 Sphinx 中記錄 Foo,self.basepathself.availableruns 屬性未顯示.這對我們 API 的用戶來說是個問題.

                  If I now use either help(Foo) or attempt to document Foo in Sphinx, the self.basepath and self.availableruns attributes are not shown. That's a problem for users of our API.

                  我嘗試尋找一種標準方法來確保解析器可以找到(最好是文檔字符串)這些動態聲明的"屬性,但到目前為止還沒有運氣.有什么建議?謝謝.

                  I've tried searching for a standard way to ensure that these "dynamically declared" attributes can be found (and preferably docstring'd) by the parser, but no luck so far. Any suggestions? Thanks.

                  推薦答案

                  你可以定義一個與實例變量同名的類變量.然后,當您設置它時,該類變量將被實例變量遮蔽.例如:

                  You could define a class variable with the same name as the instance variable. That class variable will then be shadowed by the instance variable when you set it. E.g:

                  class Foo(object):
                      #: Doc comment for availableruns
                      availableruns = ()
                  
                      def __init__(self, base):
                          ...
                          self.availableruns = tuple(sorted(temp))
                  

                  確實,如果實例變量有一個有用的不可變默認值(例如None或空元組),那么你可以通過不設置變量if應該有它的默認值來節省一點內存.當然,如果您談論的是您可能想要刪除的實例變量(例如,del foo.availableruns),這種方法將不起作用——但我發現這不是一個很常見的情況.

                  Indeed, if the instance variable has a useful immutable default value (eg None or the empty tuple), then you can save a little memory by just not setting the variable if should have its default value. Of course, this approach won't work if you're talking about an instance variable that you might want to delete (e.g., del foo.availableruns)-- but I find that's not a very common case.

                  如果您使用的是 sphinx,并且具有自動屬性";設置,那么這應該得到適當的記錄.或者,根據您正在執行的操作的上下文,您可以直接使用 Sphinx .. py:attribute:: 指令.

                  If you're using sphinx, and have "autoattribute" set, then this should get documented appropriately. Or, depending on the context of what you're doing, you could just directly use the Sphinx .. py:attribute:: directive.

                  這篇關于如何使 Python/Sphinx 文檔對象屬性僅在 __init__ 中聲明?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 包)

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

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

                        <legend id='dZj8V'><style id='dZj8V'><dir id='dZj8V'><q id='dZj8V'></q></dir></style></legend>

                          <tbody id='dZj8V'></tbody>
                        • <tfoot id='dZj8V'></tfoot>

                          1. 主站蜘蛛池模板: 亚洲精品视频久久 | 久久国产精品-国产精品 | 亚洲高清在线观看 | 色综合久久天天综合网 | 国产精品日本一区二区不卡视频 | 久久视频精品 | 国产成人精品免费 | 精品日韩一区二区三区 | 亚洲第一成人av | 久久精品aaa | 国产精品美女久久久久aⅴ国产馆 | 久草免费在线 | 亚洲黄色网址视频 | 欧美黄色性生活视频 | 黄色网址在线播放 | 亚洲国产成人精品女人久久久 | 在线观看av网站永久 | 亚洲一区二区在线播放 | 亚洲综合色站 | 国产一级一级毛片 | 毛片网在线观看 | 精品国产黄a∨片高清在线 成人区精品一区二区婷婷 日本一区二区视频 | 综合国产第二页 | 青青草中文字幕 | 91不卡在线| 久久精品国产清自在天天线 | 久久久久久91 | 国产成人在线视频播放 | 美女久久视频 | 亚洲顶级毛片 | 国产精品视屏 | 天堂成人国产精品一区 | 国产视频一区二区 | 中文在线a在线 | 国产小网站 | 丝袜久久| 亚洲精品视频在线播放 | 亚洲大片一区 | 欧美九九 | 欧美啪啪网站 | 日韩精品成人免费观看视频 |