How do I pass a list to a __init__ value/definition?
Andrew Koenig
ark at acm.org
Tue Jul 25 08:54:08 EDT 2006
<ryanshewcraft at gmail.com> wrote in message
news:1153831615.862051.98850 at h48g2000cwc.googlegroups.com...
> 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.
Really?
class MultipleRegression:
def __init__(self, dbh, regressors, fund):
self.dbh = dbh
self.regressors = regressors
foo = MultipleRegression(42, [1,2,3,4], 5)
print foo.regressors
prints [1,2,3,4]
Try it and see.
More information about the Python-list
mailing list