[Tutor] file-like object

Chad Crabtree flaxeater at yahoo.com
Sat Jan 15 01:36:21 CET 2005


Danny Yoo wrote:

>Using the default parameter 'n' in the readline() method isn't safe:
all
>class instances will end up using the same 'n'.  You may want to put
the
>current line number as part of an instance's state, since two
instances of
>a macroString should be able to keep track of their line positions
>independently.
>
>But that being said, there's already a module in the Standard
Library that
>turns strings into file-like objects.  Can you use
StringIO.StringIO?
>  
>
I used kent's solution at first but I'm just using StringIO now I
didn't 
realize what that module  did.  Thank you all for your suggestion.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Tutor mailing list