title: Object indexing in python
body: <p>I have created the following objects in python</p>
  
  <p>It creates an object of class arc and then creates another object network using the object arc</p>
  
  <pre><code>class Arc:
      # Creates an object of class arc
      def __init__(self, tailNode = 0, headNode = 0, lowerBound = 0, upperBound = 0, cost = 0):
          self.tailNode = tailNode
          self.headNode = headNode
          self.lowerBound = lowerBound
          self.upperBound = upperBound
          self.cost = cost
      def displayArc(self):
          print("Tail Node : ", self.tailNode,  "\nHead Node : ", self.headNode, "\nLower Bound : ", self.lowerBound, "\nUpper Bound ; ", self.upperBound, "\nCost : ", self.cost, "\n")
  
  class Node:
      # Create an object of class node
      def __init__(self, nodeName = 0, distLabel = 0, preNode = 0):
          self.nodeName = nodeName
          self.distLabel = distLabel
          self.preNode = preNode
  
  class Network:
       # Creates a network from given arcs
       def __init__(self, fileName):
          global arcNo 
          arcNo = 0
  
          self.fileName = fileName
          f = open(self.fileName)
          x = f.readlines()
  
          arcList = [ Arc() for i in range(len(x))]
  
      for i in range(len(x)):
          temp = x[i]
          temp = temp.split("\n")
          temp = ",".join(map(str, temp))
          temp = temp.split(",")
          arcList[i] = Arc(temp[0], temp[1], temp[2], temp[3], temp[4])
          arcNo += 1
  
      print(arcNo)
  
  net = Network("arcList.txt")
  print(type(net))
  print(net[1])
  </code></pre>
  
  <p>When the print statement comes says </p>
  
  <pre><code>4
  &lt;class '__main__.Network'&gt;
  Traceback (most recent call last):
        File "Dijkstra.py", line 54, in &lt;module&gt;
      print(net[1])
  TypeError: 'Network' object does not support indexing
  </code></pre>
  
  <p>How do I support indexing so that I can call the network object by its index ?</p>