The problem is that your class definition doesn't do anything to
explicitly set those attributes.

On Thu, Sep 23, 2010 at 4:58 AM, Roelof Wobben <rwob...@hotmail.com> wrote:
<snip>
> class tijd :
>    pass

You're not doing any explicit setting of attributes at the class level.

<snip>
> time = tijd()
> time.hour = 20
> time.minutes = 20
> time.seconds = 20

You set them on this instance.

> seconds = 20
> uitkomst = tijd()

But not on this one.

What you probably want to do is something like this:

class tijd(object):
    def __init__(self):
        self.hour = 20
        self.minutes = 20
        self.seconds = 20

Or if you prefer to set these when you create the instance, you can
pass in values like this:

class tijd(object):
    def __init__(self, hour=20, minutes=20, seconds=20):
        self.hour = hour
        self.minutes = minutes
        self.seconds = seconds

I noticed something odd just a sec ago.  You have this:
> uitkomst = tijd()
> uitkomst = increment(time, seconds)
> print uitkomst.minutes, uitkomst.seconds

You're creating a tijd instance, binding uitkomst to it, then
overwriting that instance with what you return from increment().

Anyway, hth.

- jmj
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to