def scoped_format(txt, **objects):
    """Format a string with respect to a set of objects' attributes.

    Example:

        >>> Class Foo(object):
        >>>     def __init__(self):
        >>>         self.name = "Dave"
        >>> print scoped_format("hello {foo.name}", foo=Foo())
        hello Dave

    Args:
        objects (dict): Dict of objects to format with. If a value is a dict,
            its values, and any further neted dicts, will also format with dot
            notation.
        pretty (bool): See `ObjectStringFormatter`.
        expand (bool): See `ObjectStringFormatter`.
    """
    pretty = objects.pop("pretty", RecursiveAttribute.format_pretty)
    expand = objects.pop("expand", RecursiveAttribute.format_expand)
    attr = RecursiveAttribute(objects, read_only=True)
    formatter = scoped_formatter(**objects)
    return formatter.format(txt, pretty=pretty, expand=expand)
def scoped_format ( txt , ** objects ) : pretty = objects . pop ( "pretty" , RecursiveAttribute . format_pretty ) expand = objects . pop ( "expand" , RecursiveAttribute . format_expand ) attr = RecursiveAttribute ( objects , read_only = True ) formatter = scoped_formatter ( ** objects ) return formatter . format ( txt , pretty = pretty , expand = expand )
Format a string with respect to a set of objects' attributes.

    Example:

        >>> Class Foo(object):
        >>>     def __init__(self):
        >>>         self.name = "Dave"
        >>> print scoped_format("hello {foo.name}", foo=Foo())
        hello Dave

    Args:
        objects (dict): Dict of objects to format with. If a value is a dict,
            its values, and any further neted dicts, will also format with dot
            notation.
        pretty (bool): See `ObjectStringFormatter`.
        expand (bool): See `ObjectStringFormatter`.