On 2015-12-03, Peter Otten wrote: > def my_hook_encoded(encoding, errors=None): > import io > def openhook(filename, mode): > mode = mode.replace('U', '').replace('b', '') or 'r' > return io.open( > filename, mode, > encoding=encoding, newline='', > errors=errors) > return openhook > > for line in fileinput.input( > options.files, > openhook=my_hook_encoded("utf-8", errors="ignore")): > do_stuff(line)
Perfect, thanks! > (codecs.open() instead of io.open() should also work) OK. -- The internet is quite simply a glorious place. Where else can you find bootlegged music and films, questionable women, deep seated xenophobia and amusing cats all together in the same place? --- Tom Belshaw -- https://mail.python.org/mailman/listinfo/python-list