Fredrik Lundh wrote: > gabor wrote: > >> yes, sure... but then.. it's possible to implement it also on top of >> an raise-when-error version :) > > not necessarily if raise-when-error means raise-error-in-os-listdir. >
could you please clarify? currently i see 2 approaches how to do it on the raise-when-error version: 1. dirname = u'something' try: files = os.listdir(dirname) except UnicodeError: byte_files = os.listdir(dirname.encode('encoding)) #do something with it 2. dirname = u'something' byte_files = os.listdir(dirname.encode('encoding')) for byte_file in byte_files: try: file = byte_file.decode(sys.getfsenc()) except UnicodeError: #do something else #do something the byte-string version of os.listdir remains. so all the other versions can be implemented on the top of it. imho the question is: which should be the 'default' behavior, offered by the python standard library. gabor -- http://mail.python.org/mailman/listinfo/python-list