Return to Snippet

Revision: 50838
at September 5, 2011 18:28 by dmitrydavidov


Updated Code
def enum_types(mimedb):
    i = 0
    while True:
        try:
            ctype = _winreg.EnumKey(mimedb, i)
        except EnvironmentError:
            break
        try:
            ctype = ctype.encode(default_encoding) # omit in 3.x!
        except UnicodeError:
            pass
        else:
            yield ctype
        i += 1

Revision: 50837
at September 5, 2011 18:24 by dmitrydavidov


Initial Code
def enum_types(mimedb):
            i = 0
            while True:
                try:
                    ctype = _winreg.EnumKey(mimedb, i)
                except EnvironmentError:
                    break
                try:
                    ctype = ctype.encode(default_encoding) # omit in 3.x!
                except UnicodeError:
                    pass
                else:
                    yield ctype
                i += 1

Initial URL

                                

Initial Description

                                

Initial Title
Right function \"enum_types\" in \"mimetypes.py\"

Initial Tags
python

Initial Language
Python