STINNER Victor added the comment: Serhiy Storchaka: > The documentation for hex() doesn't look the bests place for examples of > using string formatting. I think it is enough to add short references to > corresponding formatting codes.
I like Manvi B's patch with many examples. It's hard to read formatting strings, it's hard to compute the result, so full examples are just more obvious. I don't think that it hurts to add many formatting examples. I expect that most users will combine the result of bin/hex/oct with another string, so suggesting using formatting functions will probably help them to simplify the code. For example, print("x=", hex(x), "y=", hex(y)) can be written: print("x=%#x y=%#x" % (x, y)) or print("x={:#x} y={:#x}".format(x, y)) or print(f"x={x:#x} y={y:#x}") The first expression using hex() adds spaces after "=", but well, it's just to give a simple example. IMHO formatting strings are more readable. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26506> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com