[Python-de] cat in python

"Martin v. Löwis" martin at v.loewis.de
Sam Apr 1 01:05:59 CEST 2006


Andreas Jung wrote:
> Ich weiss :-) die Lösung von Martin war mir zu lang.

In Python 2.5 kannst Du noch zwei Zeilen einsparen:

import glob, shutil
with open("xxx.4gi", "w") as outfile:
   for f in glob.glob("*.4go"):
       with open(f) as infile:
           shutil.copyfileobj(infile, outfile)

Ciao,
Martin