How do I pass a list to a __init__ value/definition?
Bruno Desthuilliers
onurb at xiludom.gro
Tue Jul 25 09:20:57 EDT 2006
ryanshewcraft at gmail.com wrote:
> You guys are right it is getting passed initially. I checked in by
> printing the self.regressors in the class and it gives the list. But I
> get the error: TypeError: iteration over non-sequence for
>
> def Regress(self):
<ot>
the usual Python coding style is to use either all_lowercase
(preferably) or mixedCase names for functions/methods names
</ot>
> print self.regressors
> for reg in self.regressors:
> index = HedgeFund(self.dbh, reg)
> indexTS[reg] = FundReturnSeries(dbh,index, sd, ed)
Names 'sd' and 'ed' are undefined.
> indexNames[reg] = index.Name()
> header.append(index.Name())
> header.append("t-statistic")
> header.append("r-squared")
> fh_csv.writerow(header)
>
> and when I print self.regressors here it only gives me the first number
> in the list. This bit of code is directly below the __init__ method.
> Any ideas what I'm doing wrong?
Sorry, I lack the needed psychic powers to find a bug in a code I can't
see !-)
Some wild guesses:
* you overwrite self.regressors somewhere else
* there's at least one case where you instanciate MultipleRegression
with someting that is not iterable.
FWIW, always try to reduce code to the minimal runnable snippet
exhibiting the problem, so others have a chance to help you. As a
side-effect, one very often finds the problem while doing so !-)
HTH
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"
More information about the Python-list
mailing list