share info between methods in a Class

G

Garcia, Paul D

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top