Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I’ve not seen many of your <code>field_map</code>s in real life. I think that would only make sense if you were to use the <code>field_map</code> at some other place in your code as well.</p> <p>Concerning your third example: Even though you don’t need to assign to them (other than <code>None</code>), it is common practice to explicitly declare attributes in the <code>__init__</code> method, so you’ll easily see what properties your object has.</p> <p>So the following is better than simply having an empty <code>__init__</code> method (you’ll also get a higher <em>pylint</em> score for that):</p> <pre><code>class Blah(object): def __init__(self): self.foo = None self.bar = None blah = Blah() blah.foo = var1 </code></pre> <p>The problem with this approach is, that your object might be in a not well-defined state after initialisation, because you have not yet defined all of your object’s properties. This depends on your object’s logic (logic in code and in meaning) and how your object works. If it is the case however, I’d advise you <strong>not</strong> to do it this way. If your object relies on <code>foo</code> and <code>bar</code> to be meaningfully defined, you <em>should</em> really put them inside of your <code>__init__</code> method.</p> <p>If, however, the properties <code>foo</code> and <code>bar</code> are not mandatory, you’re free to define them afterwards.</p> <p>If readability of the argument lists is an issue for you: Use keyword arguments.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload