Hallo Liste, Für euch warscheinlich eine Kleinigkeit, ich suche mir momentan einen Wolf. Ich suche für folgenden bash-Aufruf das äquivalent in python cat *.4go > xxx.4gi -- cu Roland Kruggel mailto: rk.liste@bbf7.de System: Intel 3.2Ghz, Debian etch, 2.6.15, KDE 3.4 _______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de
Roland M. Kruggel wrote:
Ich suche für folgenden bash-Aufruf das äquivalent in python cat *.4go > xxx.4gi
import glob, shutil outfile = open("xxx.4gi", "w") for f in glob.glob("*.4go"): infile = open(f) shutil.copyfileobj(infile, outfile) infile.close() outfile.close() HTH, Martin _______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de
--On 30. März 2006 21:00:22 +0200 "\"Martin v. Löwis\""
Roland M. Kruggel wrote:
Ich suche für folgenden bash-Aufruf das äquivalent in python cat *.4go > xxx.4gi
oder die 1-Zeiler Version: import glob; open('xxx.4gi','w').write(''.join([open(f).read() for f in glob.glob('*.4go')])) -aj _______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Andreas Jung schrieb:
oder die 1-Zeiler Version:
import glob; open('xxx.4gi','w').write(''.join([open(f).read() for f in glob.glob('*.4go')]))
Damit bekommst Du aber in Software-Design eine "6". - -- Schönen Gruß - Regards Hartmut Goebel | Hartmut Goebel | IT-Security -- effizient | | h.goebel@goebel-consult.de | www.goebel-consult.de | -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) Comment: Using GnuPG with Mandriva - http://enigmail.mozdev.org iQEVAwUBRCzYB8zajR0mSa83AQIViAf+OraxuagJRG6XYifFt79MGDbo9u7lFyMG JIwQTnjRTCzgcD7wDo9YBNlcMqzxAzGbQ4Qv3zeXB9xdczqnEN/VeyUWu5j9UDd6 9Ywgr24tkFEEJc6MlvA7W8uSxf5BjvuIMWF3u1/mOKYSgbykFTDxaqo5rWPfQNxC 6pT0Zh8YuyYhm6SUhdWjG53yl5EYT9ppQQr3XLF7sI6UO0YWsv8GJHd50PJM9Xm3 VvJ0A19DDTbTkrs3qWiMmZ8egndRfsj9TiNFrGlZDZkBYXQCG/asIypYUFaQuPrF 7H0ma1/onh/zqRttNCQzvXEhfBp9S1JJ+ZACY70qEJZqWPYB0uO/Jg== =T+Lp -----END PGP SIGNATURE----- _______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de
--On 31. März 2006 09:19:35 +0200 Hartmut Goebel
oder die 1-Zeiler Version:
import glob; open('xxx.4gi','w').write(''.join([open(f).read() for f in glob.glob('*.4go')]))
Damit bekommst Du aber in Software-Design eine "6".
Ich weiss :-) die Lösung von Martin war mir zu lang. SCNR, Andreas _______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Andreas Jung schrieb:
Ich weiss :-) die Lösung von Martin war mir zu lang.
Hmm, dann solltest Du überlegen, doch zu Perl zu wechseln ;-) - -- Schönen Gruß - Regards Hartmut Goebel | Hartmut Goebel | IT-Security -- effizient | | h.goebel@goebel-consult.de | www.goebel-consult.de | -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) Comment: Using GnuPG with Mandriva - http://enigmail.mozdev.org iQEVAwUBRCzb78zajR0mSa83AQJ48gf/QzzG3TkOAp1L5ISywTDNAFXijBnLC18g ScdFufIEH9kgJAKZczfHslvYay4SKiIrEoAa4sEhb8l2E8UgsQnlfDjw3bnVhHdY geGoxs8g+f1wUlBhqYl7fb37kc82fSeSc0H8QC+XZzcpPxqEk/imMwXY/Q7b9ArH AWaBxJs8O7aam7wlHQfJQyEB0BTr1ObJ4k8s0/Ahv+F3zzXYslA+NSVJMcL+Q36/ h9ePEvEWvemN/nQf8YEWkaTt3glUeCbnm1+P0odfbH4NV7fzx+kMrxBEXw8OmDJb L6qc0Lj6UUBrlqF+Gfi6b+HxnRO2OPtpqED4VDdqNeusmjzdm17SJQ== =y4BM -----END PGP SIGNATURE----- _______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de
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 _______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Martin v. Löwis schrieb:
import glob, shutil
outfile = open("xxx.4gi", "w") for f in glob.glob("*.4go"): infile = open(f) shutil.copyfileobj(infile, outfile) infile.close() outfile.close()
Ich dachte, das wäre endlich mal eine Anwendung für das Module 'fileinput'. Aber shutil.copyfileobj ist da wesendlich elleganter und effizienter. - -- Schönen Gruß - Regards Hartmut Goebel | Hartmut Goebel | IT-Security -- effizient | | h.goebel@goebel-consult.de | www.goebel-consult.de | -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) Comment: Using GnuPG with Mandriva - http://enigmail.mozdev.org iQEVAwUBRCzZMszajR0mSa83AQLkGAgAkuM4x+whmMnWfHsvNhUeAueTxpXMO8Qf OSjbSKCsXOV92gFo7oK6zobHES1TgSX9Dz71NtfhwAdgE6XL6WHzZjoHZMrESTff F9MaT948upJgOgmQ+S01wo6hrEMi2xk7khrRUSmM15i2gSq4GB+H/zed5CGds6LK D+kPq4YyvmntQEmm1U5rI0eAIc5bLbmlw6xLngLWjL/PAEAYiIt+hWBUzvsbkuA7 9S6MEGpvfetksOYhguAftszPeQ0mE8IaF9rqAzflwGngbhEapethRGyor8YtcG3z PufW0vszKnZfReDNumrMZXJ7fiRPQfsk2jTgZDgm785B5qWbMyocuA== =ZtmP -----END PGP SIGNATURE----- _______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de
participants (4)
-
"Martin v. Löwis"
-
Andreas Jung
-
Hartmut Goebel
-
Roland M. Kruggel