[Tutor] timed functions? Timeouts?

Kent Johnson kent37 at tds.net
Tue May 20 14:18:06 CEST 2008


On Mon, May 19, 2008 at 11:23 PM, W W <srilyk at gmail.com> wrote:
> Those examples are really helpful and I'm pretty sure they'll do what
> I need, I'll just have to play with them a little more.
>
> I do have a question about one of the examples though!
>
> Specifically this part:
>
>  4 class Operation(threading._Timer):
>  5     def __init__(self, *args, **kwargs):
>  6         threading._Timer.__init__(self, *args, **kwargs)
>  7         self.setDaemon(True)
>
> So in trying to understand the class definition, I found this:
>
> "In Python, the ancestor of a class is simply listed in parentheses
> immediately after the class name."
>
> So does that mean that Operation is similar or the same as say:
>
> Operation = threading._Timer?

No.

class Operation(threading._Timer)
creates a new class called Operation that inherits from
threading._Timer. I.e. threading._Timer is the base class, or
superclass, of Operation.

Operation = threading._Timer
this just makes the name Operation be an alias for threading._Timer;
it doesn't create a new class.

> Then I'm a little confused by the * and ** - they look just like the
> pointer and pointer to a pointer in C++, but do they perform the same
> function in python?

No, these are not pointers, they allow passing arbitrary lists and
dicts of arguments. I don't know of a good writeup of this syntax;
here are some pointers:
http://bytes.com/forum/thread25464.html

Kent


More information about the Tutor mailing list