Continually check object status

futileissue at gmail.com futileissue at gmail.com
Sat Aug 2 19:48:45 CEST 2008


On Aug 2, 12:58 pm, Gary Herron <gher... at islandtraining.com> wrote:
> futileis... at gmail.com wrote:
> > Beginner, so please bare with me.  I'm not sure what to call what it
> > is I'm looking for.
>
> > If I have an object class, let's call it "Creature":
>
> > class Creature:
> >     def __init__(self, status):
> >         self.status = "happy"
>
> >     def change_status(self, new_status):
> >         self.status = new_status
>
> >     def print_status(self):
> >         print self.status
>
> > I would like to be able to print out the Creature's status every 20
> > seconds.  Let's say I use a script like this:
>
> > import time
> > while True:
> >     time.sleep(20)
> >     Creature.print_status()
>
> > But, while cycling through printing the status, I would like to be
> > able to update Creature.status to something new.
>
> To answer your question, we need to know from where you would derive the
> directions to change the status.  For instance:
>   * time based (random or periodically scheduled)
>   * user mouse/keyboard action
>   * some state external to the program (file content, socket data, phase
> of the moon, price of tea in China, ...)
>
> Each of those possibilities would require a substantially different
> approach.
>
> Gary Herron
>
> > I might be approaching this from the wrong direction entirely.  Thanks
> > for your input.
> > --
> >http://mail.python.org/mailman/listinfo/python-list
>
>

I was thinking about it taking directions from a GTK event handler,
such as a user selecting a button.



More information about the Python-list mailing list