[Tutor] Python 3: List Comprehensions + range

Juan Christian juan0christian at gmail.com
Sun Sep 21 21:32:05 CEST 2014


On Sun, Sep 21, 2014 at 4:21 PM, Joel Goldstick <joel.goldstick at gmail.com>
wrote:
>
> Shouldn't it be:  Season(ID, season, serie)?


No, we always have to have 'self' in the first arg.


On Sun, Sep 21, 2014 at 4:25 PM, Danny Yoo <dyoo at hashcollision.org> wrote:
>
> Please treat email as asynchronous: sometimes you'll get a response
> within minutes, but sometimes it takes a little longer.
>
> Reading the question quickly... I can't answer this too carefully.  I
> haven't even had breakfast or lunch yet!  :P
>
>
> But there appears to be a type error here.  You're using the name
> "season" in different contexts, where sometimes you mean the season
> number, and in other places, you mean the season object.
> Particularly, you appear to expect the constructor of Episode to take
> in the season *number*, but within the Season constructor, you're
> passing it the season *object*.
>

 Time here is different then =p

And, no, I always treat season as a number, like season 1, 2, 3, ...

In the class Season, I use season twice: on the response, s = season,
giving s the season number. And self.number = season, giving, self.number,
the season number, only that!

And in the class Serie, the line self.season = [Season(ID, season, self)
for season in range(1, self.size + 1)], self.season is the object, and
season is just a random var that I used in the list.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140921/b730525d/attachment.html>


More information about the Tutor mailing list