import zlib
-import sys
-
class ObjectDict(dict):
"""Makes a dictionary behave like an object, with attribute-style access.
"""
True
>>> import_object('tornado') is tornado
True
- >>> import_object('missing_module')
- Traceback (most recent call last):
- ...
- ImportError: No module named missing_module
>>> import_object('tornado.missing_module')
Traceback (most recent call last):
...
try:
return getattr(obj, parts[-1])
except AttributeError:
- exc_info = sys.exc_info()
- raise ImportError, "No module named %s" % parts[-1], exc_info[2]
+ raise ImportError("No module named %s" % parts[-1])
+
# Fake unicode literal support: Python 3.2 doesn't have the u'' marker for
# literal strings, and alternative solutions like "from __future__ import