title: good practices to extend a class with custom functions in python: when to apply and how to code it?
body: <p>I am not sure if question is posed correctly:</p>
  
  <p>I am working with a library, as an example in this case networkx, and building functions manipulating networkx classes (graphs).</p>
  
  <p>Example:</p>
  
  <pre><code>def myfunction( graph, params ):
     # do something 
  </code></pre>
  
  <p>For the sake of learning better coding and readability, when does it make sense to extend a graph class so that I can use myfunction as:</p>
  
  <pre><code>import networkx
  
  mygraph = networkx.Graph()
  mygraph.myfunction(params)  #mygraph is an instance of graph class of networkx 
  #myfunction can be applied to all graphs instances of networkx
  #without passing graphs as parameter
  </code></pre>
  
  <p>?</p>
  
  <p>A few examples for doing it with comments when would make sense for doing it?</p>