[Tutor] Avoiding the use of files to store intermediate results

Andre Roberge andre.roberge at gmail.com
Wed Apr 26 03:45:19 CEST 2006


On 4/25/06, Hugo González Monteverde <hugonz-lists at h-lab.net> wrote:
> Remember duck typing. An object just needs to look like a file in order
> to be used like one.
>
> Guido's time machine has already forseen your problem. Take a look at
> the StringIO module.  It allows you to use a string where you would
> normally pass a file object.
>

Since I do something like
os.open("python some_file.py > some_output")
I don't see how I can pass a file-like object.  As far as I can tell
"python" (the command) looks for a real file on the current path.

André

> Hope that helps,
>
> Hugo
>
> > ######
> > While this works, I find it "messy", as it creates some intermediate
> > files.  I was wondering if there was a better way to do things all in
> > memory, in an OS independent way.
> >
> > [Note that the complete application is approximately 665 lines long
> > ... a bit too much
> > to post all here :-)]
> >
> > André
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
>


More information about the Tutor mailing list