Add lists to class?

BBands bbands at gmail.com
Thu Sep 1 16:18:21 EDT 2005


I have a list with some strings in in it, 'one', 'two' 'three' and so
on. I would like to add lists to a class with those names. I have no
way of knowing what will be in the list or how long the list will be in
advance.

Something like:

class master:
    def __init__(self, list):
        self.count = len(list)
        for line in list:
            self.line = [] # obviously this doesn't work

list = ['one', 'two', 'three']

a = master(list)

so that I get:

dir(a)

['_doc__', '_init__', '_module__', 'one', 'two', 'three']

instead of:

dir(a)

['_doc__', '_init__', '_module__', 'line']


TIA,

     jab




More information about the Python-list mailing list