title: Python creating more then one object from a single class IN the class
body: <p>I would like to create 5 objects (serial number, part number, card name, card status, card type). My code takes in a file which contains some strings (Information about each card). As you can see from the code, I am creating only one object right before the for loop in the main function. I would like to create the object where it says "create the object here". The object is card, each card has a part number, serial number, name, status and type. When I run this code, it only output's the Card-Name because it is only creating one object. However, if I put them all in an array or dictionary and I output that, then it will output everything (again because it is creating one object ONLY). How can I get it to output all of these informations. I know my problem is with the way I am creating the object. I am new to python, so any help would greatly be appreciated. Also, yes I would like all of my variables to be private.</p>
  
  <pre><code>###############
  #output:
  #Card-Name:  CPM B
  #Serial-Number:
  #part-Number:
  #Card-Status:
  #Card-Type
  ##############
  
  class Slot(object):
    card_sn = ""
    card_pn = ""
    card_name = ""
    card_status = ""
    card_type = ""
  
    def __init__(self):
      self.__card_sn = ""
      self.__card_pn = ""
      self.__card_name = ""
      self.__card_status = ""
      self.__card_type = ""
  
    def CPM_detail(self,input,region,subregion):
        temp = re.search(r'(\s+)Card (A|B|C|D)',input)
        if temp:
          ############
          #would like to create the object here
          ############
          self.__card_name = "CPM "+str(temp.group(2))                         
          temp = re.search(r'Memory capacity',input)
          if temp:
            self.__card_type = temp.group(1)
          temp = re.search(r'\s{10,}(\S+)\s{20,}',input)
          if temp:
            self.__card_status = str(temp.group(1))
          temp = re.search(r'(\s+)Serial number(\s+): (\S+)',input)
          if temp:
             self.__card_sn = temp.group(3)
          temp = re.search(r'(\s+)Part number(\s+): (\S+)',input)
          if temp:
             self.__card_pn = temp.group(3)
  
    def serial_number(self):
      return self.__card_sn
    def part_number(self):
      return self.__card_pn
    def card_name(self):
      return self.__card_name
    def card_status(self):
      return self.__card_status
    def card_type(self):
      return self.__card_type
  
  
  def main():
    with open ('/home/thamer/TS_ncren202_XRS-20_20150624_12.0.R6.txt','r') as f:
      slot_cards = Slot()
      for line in f: 
        slot_cards.CPM_detail(line,region,subregion)
        serialNumber = slot_cards.serial_number()
        partNumber = slot_cards.part_number()
        cardName = slot_cards.card_name()
        cardStatus = slot_cards.card_status()
        cardType = slot_cards.card_type()
        print "Card-Name: ",cardName
        print "Serial#: ",serialNumber
        print "part#: ",partNumber
        print "Card-Status: ",cardStatus
        print "Card-Type ",cardType 
  
  
  if __name__ == '__main__':
    main()
  </code></pre>