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

Splitting python path using os.path module

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

To speed up accessing files on nfs shares on a ubuntu machine ...