Re: Using the 'with' statement with cStringIO objects

2008-09-30 Thread Gabriel Genellina
En Sat, 27 Sep 2008 19:28:49 -0300, peppergrower <[EMAIL PROTECTED]> escribió: When I got that particular error, I suspected that it had something to do with the relative newness of the 'with' statement. If this is something that should be considered for addition in the future, is there somew

Re: Using the 'with' statement with cStringIO objects

2008-09-27 Thread peppergrower
Thanks for the help. I'm fairly new to programming (which you probably could have guessed...). When I realized that you could use a StringIO instance as if it were a file, I wanted to try some of the same techniques on it as I would with a file. In this case, I wanted to use a "for line in testf

Re: Using the 'with' statement with cStringIO objects

2008-09-27 Thread Hrvoje Niksic
George Boutsioukis <[EMAIL PROTECTED]> writes: > Neither, just not implemented. Only classes with __enter__ and > __exit__ methods(ie context manager types) can be used in with > statements. And, correct me if I'm wrong, I think it's pointless for > a StringIO object to have those. It's definitel

Re: Using the 'with' statement with cStringIO objects

2008-09-27 Thread George Boutsioukis
> So, I'm guessing you can't use the 'with' statement with cStringIO > objects? Is this a bug, or do I need to use the 'with' statement > differently to get this to work? > > Thanks, > peppergrower Neither, just not implemented. Only classes with __enter__ and __exit__ methods(ie context manag

Re: Using the 'with' statement with cStringIO objects

2008-09-27 Thread Fredrik Lundh
peppergrower wrote: teststring='this is a test' with cStringIO.StringIO(teststring) as testfile: pass umm. what exactly do you expect that code to do? -- http://mail.python.org/mailman/listinfo/python-list

Using the 'with' statement with cStringIO objects

2008-09-27 Thread peppergrower
I've been experimenting with the 'with' statement (in __future__), and so far I like it. However, I can't get it to work with a cStringIO object. Here's a minimum working example: ### from __future__ import with_statement import cStringIO teststring='this is a test' with cStringIO.StringIO(tes