<reponame>milancermak/tornado<gh_stars>1-10
"""Miscellaneous utility functions."""

def import_object(name):
    """Imports an object by name.

    import_object('x.y.z') is equivalent to 'from x.y import z'.

    >>> import tornado.escape
    >>> import_object('tornado.escape') is tornado.escape
    True
    >>> import_object('tornado.escape.utf8') is tornado.escape.utf8
    True
    """
    parts = name.split('.')
    obj = __import__('.'.join(parts[:-1]), None, None, [parts[-1]], 0)
    return getattr(obj, parts[-1])

def doctests():
    import doctest
    return doctest.DocTestSuite()

"""Miscellaneous utility functions."""

def import_object(name):
    """Imports an object by name.

    import_object('x.y.z') is equivalent to 'from x.y import z'.

    >>> import tornado.escape
    >>> import_object('tornado.escape') is tornado.escape
    True
    >>> import_object('tornado.escape.utf8') is tornado.escape.utf8
    True
    """
    parts = name.split('.')
    obj = __import__('.'.join(parts[:-1]), None, None, [parts[-1]], 0)
    return getattr(obj, parts[-1])

def doctests():
    import doctest
    return doctest.DocTestSuite()
Miscellaneous utility functions. Imports an object by name.      import_object('x.y.z') is equivalent to 'from x.y import z'.      >>> import tornado.escape     >>> import_object('tornado.escape') is tornado.escape     True     >>> import_object('tornado.escape.utf8') is tornado.escape.utf8     True