[Tutor] question about operator overloading

Joel Goldstick joel.goldstick at gmail.com
Tue Mar 6 00:35:57 CET 2012


On Mon, Mar 5, 2012 at 6:20 PM, Alan Gauld <alan.gauld at btinternet.com> wrote:
> On 05/03/12 21:25, Dave Angel wrote:
>
>> It's not clear what __add__() should mean for physical files.
>
>
> My guess would be similar to the cat operator in Unix:
>
> $ cat file1, file2 > file3
>
> is equivalent to
>
> file3 = file1 + file2
>
> But of course, thats just my interpretation of file addition...
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

if spss files are text (not binary) why not:

f1 = open("f1")read()
f2 = open("f2")read()

outfile = open("outfile", "w")
outfile.write(f1 + f2)
outfile.close()

You could put this in a function and pass all infiles as *filenames,
then loop to read each file and output result



-- 
Joel Goldstick


More information about the Tutor mailing list