Quantcast
Channel: Reopening a closed stringIO object in Python 3 - Stack Overflow
Browsing latest articles
Browse All 5 View Live

Answer by user6035109 for Reopening a closed stringIO object in Python 3

I have a nice hack, which I am currently using for testing (Since my code can make I/O operations, and giving it StringIO is a nice get-around).If this problem is kind of one time thing:st =...

View Article


Answer by 9716278 for Reopening a closed stringIO object in Python 3

When you f.close() you remove it from memory. You're basically doing a deref x, call x; you're looking for a memory location that doesn't exist.Here is what you could do in stead:import ioa = 'Me, you...

View Article


Answer by raphaelhuefner for Reopening a closed stringIO object in Python 3

No, there is no way to re-open an io.StringIO object. Instead, just create a new object with io.StringIO().Calling close() on an io.StringIO object throws away the "file contents" data, so re-opening...

View Article

Answer by ldiary for Reopening a closed stringIO object in Python 3

The builtin open() creates a file object (i.e. a stream), but in your example, f is already a stream.That's the reason why you get TypeError: invalid fileAfter the method close() has executed, any...

View Article

Reopening a closed stringIO object in Python 3

So, I create a StringIO object to treat my string as a file:>>> a = 'Me, you and them\n'>>> import io>>> f = io.StringIO(a)>>> f.read(1)'M'And then I proceed to...

View Article

Browsing latest articles
Browse All 5 View Live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>