News for hackers. Stuff that matters.
Re:Be Careful with Python's New-Style String Format by antsar on Saturday December 31, 2016 @06:16PM (#13293723)
Attribute access doesn't seem to work with old-style formatting, so I would think it's safe.

    >>> class foo:
    ...     def __init__(self, **kwargs):
    ...             self.__dict__.update(kwargs)
    ...
    >>> my_foo = foo(secret="bazinga")
    >>>
    >>> "%(foo)s" % {'foo': my_foo}
    '<__main__.foo instance at 0x1101d23f8>'
    >>>
    >>> "%(foo.secret)s" % {'foo': my_foo}
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    KeyError: 'foo.secret'

There are no comments on this comment yet.