Class functions

Chad Maine chad.maine at broadlink.com
Thu Feb 28 12:50:55 EST 2002


I was able to solve the problem using generators and replacing the StringIO
file object with a simple yield.  Fortunately, we had already moved our
development to Python 2.2 for other reasons.

Thanks to Jason Orendorff for the tip.


"Chad Maine" <chad.maine at broadlink.com> wrote in message
news:NVSe8.151$en5.1429 at typhoon.sonic.net...
> I'd like to access the data updated in real time via a class' function.
> I've got something like this:
>
> the class:
>
> def CLASS:
>     def __init__...
>
>     def __del__...
>
>     def FUNC(self):
>         while 1:
>             self.DATA = StringIO.StringIO(UPDATE)
>             if self.DATA == '': break
>         self.DATA.close()
>
> in my client script:
>
> import theclass
> X = theclass.CLASS
> X.FUNC()
> while 1:
>     try:
>         DATA = self.DATA
>         if not DATA: break
>         print DATA.read()
>     except ValueError:
>         break
>
>
>





More information about the Python-list mailing list