Now for the flames...
ben at co.and.co
ben at co.and.co
Sat Jun 24 07:16:53 EDT 2000
David Broadwell <dbroadwell at mindspring.com> wrote:
> Ok, now, what else am i doing that really isn't necessary?
> (ie: point out my c hangups, please.)
Some minor optimisations:
On a Unix system:
$ find . -name '*.m3u' -exec cat {} \; > outfile
In python:
import os.path
def all_m3u(outputfile, dirname, names):
ext = ''
root = ''
f = None
for name in names:
root, ext = os.path.splitext(name)
if ext == '.m3u':
f = open(os.path.join(dirname, name))
outputfile.write(f.read())
f.close()
def doit(dir, outputfile):
f = open(outputfile, 'w')
os.path.walk(dir, all_m3u, f)
f.close()
if __name__ == '__main__':
doit('.', 'outputfile')
Greetings,
--
ben . de . rydt at pandora . be ------------------ your comments
http://users.pandora.be/bdr/ ------- inl. IPv6, Linux en Pandora
More information about the Python-list
mailing list