title: Methods vs. Properties
body: <p>I'm working on the Python API for our physics simulation package (Mechanica, <a href="https://mechanica.readthedocs.io" rel="nofollow noreferrer">https://mechanica.readthedocs.io</a>), and mulling over wether to use properties or methods.</p>
  <p>Python has an established convention that of the objects in a dictionary are accessible by an <code>items()</code> method, i.e.</p>
  <pre><code>[i for i in d.items()]
  </code></pre>
  <p>I'm trying to adhere to this established convention for our objects, but it's sometimes awkward, for example, in our simulator, we have:</p>
  <pre><code>C.items()                   # get all the members of this
                              # type
  n = a.neighbors()           # get all the neighbors of an object
  c = find_some_cluster()     # some function to find a cluster     
  c.items()                   # get all the items in ths list
  b = m.bind(pot, a, b)       # create a bond between two objects
  b.energy()                  # gets the current energy of the bond
  b.half_life                 # gets / sets the half life
  b.delete()                  # deletes the bond 
  b.items()[0], b.items()[1]  # gets the pair of objects that this bond acts on. 
  b.dissociation_energy       # bond breaking threshold
  </code></pre>
  <p>To access one of the of objects a that a bond is between, you currently have to call</p>
  <pre><code>b.items()[0]
  </code></pre>
  <p>I think that's awkward, and perhaps <code>items</code> would be better as a property. I just don't know though, because if I made it a property, that goes agains the some of the established Python convention.  Python itself is pretty inconsistent where some things are a stand-alone function, i.e. <code>len(a)</code> for length of a list, but most other things are methods on objects.</p>
  <p>Our bond object, some things on it are methods, like <code>energy()</code>, but others are properties, like <code>half_life</code>. I set these up this way, because half_life is actually a stateful property of the object, but <code>energy()</code> is a computed thing. I’m not sure if this makes the most sense to the end user though.
  What do you guys think our <code>items</code> should be, a method or property. Is there any good rule to apply as to when something should be a method or property.</p>