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


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. def enum_types(mimedb):
  2. i = 0
  3. while True:
  4. try:
  5. ctype = _winreg.EnumKey(mimedb, i)
  6. except EnvironmentError:
  7. break
  8. try:
  9. ctype = ctype.encode(default_encoding) # omit in 3.x!
  10. except UnicodeError:
  11. pass
  12. else:
  13. yield ctype
  14. i += 1

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.