<tfoot id='H4uTK'></tfoot>

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

      • <bdo id='H4uTK'></bdo><ul id='H4uTK'></ul>
        <i id='H4uTK'><tr id='H4uTK'><dt id='H4uTK'><q id='H4uTK'><span id='H4uTK'><b id='H4uTK'><form id='H4uTK'><ins id='H4uTK'></ins><ul id='H4uTK'></ul><sub id='H4uTK'></sub></form><legend id='H4uTK'></legend><bdo id='H4uTK'><pre id='H4uTK'><center id='H4uTK'></center></pre></bdo></b><th id='H4uTK'></th></span></q></dt></tr></i><div id='H4uTK'><tfoot id='H4uTK'></tfoot><dl id='H4uTK'><fieldset id='H4uTK'></fieldset></dl></div>
      1. <legend id='H4uTK'><style id='H4uTK'><dir id='H4uTK'><q id='H4uTK'></q></dir></style></legend>
      2. setattr 与 kwargs,pythonic 与否?

        时间:2023-09-03

          <tfoot id='uYbJ4'></tfoot>
        • <legend id='uYbJ4'><style id='uYbJ4'><dir id='uYbJ4'><q id='uYbJ4'></q></dir></style></legend>

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

              <tbody id='uYbJ4'></tbody>

              1. <i id='uYbJ4'><tr id='uYbJ4'><dt id='uYbJ4'><q id='uYbJ4'><span id='uYbJ4'><b id='uYbJ4'><form id='uYbJ4'><ins id='uYbJ4'></ins><ul id='uYbJ4'></ul><sub id='uYbJ4'></sub></form><legend id='uYbJ4'></legend><bdo id='uYbJ4'><pre id='uYbJ4'><center id='uYbJ4'></center></pre></bdo></b><th id='uYbJ4'></th></span></q></dt></tr></i><div id='uYbJ4'><tfoot id='uYbJ4'></tfoot><dl id='uYbJ4'><fieldset id='uYbJ4'></fieldset></dl></div>
                • <bdo id='uYbJ4'></bdo><ul id='uYbJ4'></ul>
                  本文介绍了setattr 与 kwargs,pythonic 与否?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在一些具有许多参数(最多 20 个)的 SQLAlchemy ORM 类中使用像这样的 __init__().

                  I'm using __init__() like this in some SQLAlchemy ORM classes that have many parameters (upto 20).

                  def __init__(self, **kwargs):
                      for k, v in kwargs.iteritems():
                          setattr(self, k, v)
                  

                  这样设置属性是pythonic"吗?

                  Is it "pythonic" to set attributes like this?

                  推荐答案

                  是的.另一种方法是.

                  def __init__(self, **kwargs):
                      self.__dict__.update( kwargs )
                  

                  这篇关于setattr 与 kwargs,pythonic 与否?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Python - 初始化多个列表/行 下一篇:使用相同的布尔值初始化列表

                  相关文章

                    • <bdo id='dN5Nm'></bdo><ul id='dN5Nm'></ul>

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

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

                    1. <i id='dN5Nm'><tr id='dN5Nm'><dt id='dN5Nm'><q id='dN5Nm'><span id='dN5Nm'><b id='dN5Nm'><form id='dN5Nm'><ins id='dN5Nm'></ins><ul id='dN5Nm'></ul><sub id='dN5Nm'></sub></form><legend id='dN5Nm'></legend><bdo id='dN5Nm'><pre id='dN5Nm'><center id='dN5Nm'></center></pre></bdo></b><th id='dN5Nm'></th></span></q></dt></tr></i><div id='dN5Nm'><tfoot id='dN5Nm'></tfoot><dl id='dN5Nm'><fieldset id='dN5Nm'></fieldset></dl></div>