How do I pass a list to a __init__ value/definition?
ryanshewcraft at gmail.com
ryanshewcraft at gmail.com
Tue Jul 25 08:46:55 EDT 2006
Let me start with my disclaimer by saying I'm new to computer
programming and have doing it for the past three weeks. I may not be
completely correct with all the jargon, so please bear with me.
Anyways, I'm writing a function which has a class called
"MultipleRegression." I want one of the variables under the __init__
method to be a list. I've got:
class MultipleRegression:
def __init__(self, dbh, regressors, fund):
self.dbh = dbh
self.regressors = regressors
and I want to be able to enter regressors as a list like
MultipleRegression(dbh, [1,2,3,4], 5). But when I do this only the 1
gets passed to regressors and thus to self.regressors. Is there any
simple way to fix this? Keep in mind that the length of the list may
vary, so I can't just create a set number of variables and then mash
them together into a list.
Thanks so much! I really am getting into this whole programming thing.
Its real challenging and very useful for my work.
More information about the Python-list
mailing list