Using repr instead of str for parameters (not objects) for disambiguity

    >>> for e in (0, "0", None, "None", 1.23, "1.23", [1,2], {"foo": "bar"}):
    ...   print "%r" % e
    ...
    0
    '0'
    None
    'None'
    1.23
    '1.23'
    [1, 2]
    {'foo': 'bar'}

When %s is used to interpolate to string there could be a bit of ambiguity introduced.
    >>> for e in (0, "0", None, "None", 1.23, "1.23", [1,2], {"foo": "bar"}):
    ...   print "%s" % e
    ...
    0
    0
    None
    None
    1.23
    1.23
    [1, 2]
    {'foo': 'bar'}

Comments

Popular posts from this blog

Multiple repeat error when the regex has multiple wildcards in python re module

Avoid using global/class-level mutable datatypes like list/dicts

Weakref proxy is for instance only ...