Danny Yoo wrote: >> I want to use the module StringIO as read and write strings as files, >> I looked into document but cannot understand. Could anyone give me a >> simple example? >> >> something like: >> from StringIO import * >> fin = StringIO("abc") >> ..... >> How can I used fin? > > 'fin' is a file-like object at this point, so you can do things like: > > fin.read(1) > > to get a single byte. The list of things we can do with file-like > objects is here: > > http://www.python.org/doc/lib/bltin-file-objects.html > > > Does this help? Good luck! Actually, what I want is creating a kind of file that is just located in memory not file system. I want to have a filename for my convert(inputFileName, outputFileName) How can I get filename? doing: fin.name() is impossible!
All above, I want to test it in unittest. > > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor