share info between methods in a Class

Discussion in 'Python' started by Garcia, Paul D, Feb 24, 2011.

  1. What is the best way to access/change list or dictionary information between methods in the same class?

    Note : I would normally have the input_list originally populate by reading in a file.

    Currently I have:

    ++++
    class Action:

    def __init__(self):

    self.input_List = list()
    self.output_List = list()

    self.ID_Name_Dict = dict()
    self.ID_Serial_Dict = dict()

    def get_Info(self, bldg=None):

    self.input_List = '1111111 Tom xyz-001 Enabled', '2222222 Dick xyz-002 Disabled', '3333333 Harry xyz-003 Enabled', \
    '4444444 Jane abc-999 Disabled', '5555555 Holly xyz-999 Enabled', '6666666 Mary xyz-004 Enabled'

    for line in self.input_List:
    if line.find('Disabled') <= 0:

    item = line.split()
    ID = item[0]
    Name = item[1]
    Serial = item[2]

    self.ID_Name_Dict[ID] = Name
    self.ID_Serial_Dict[ID] = Serial

    def parse_Info(self, bldg=None):

    for each in self.ID_Name_Dict:
    if each.find('xyz') >= 0 and each.find('-999') <= 0:
    self.input_List.append(each)
    else:
    self.output_List.append(each)

    ++++

    If this is not correct, can anyone provide some guidance?

    thanks,

    pg
     
    Garcia, Paul D, Feb 24, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John M. Gabriele
    Replies:
    18
    Views:
    1,156
    Steven Bethard
    Feb 18, 2005
  2. K. Jansma
    Replies:
    7
    Views:
    328
    Duncan Booth
    Feb 21, 2006
  3. Saraswati lakki
    Replies:
    0
    Views:
    1,341
    Saraswati lakki
    Jan 6, 2012
  4. Jack
    Replies:
    2
    Views:
    217
  5. Kenneth McDonald
    Replies:
    5
    Views:
    321
    Kenneth McDonald
    Sep 26, 2008
Loading...

Share This Page