What's New In Python 3.6


Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content
PEP 498: Formatted string literals

PEP 515: Underscores in Numeric Literals

PEP 515 adds the ability to use underscores in numeric literals for improved readability. For example:

>>> 1_000_000_000_000_000
>>> 0x_FF_FF_FF_FF

Single underscores are allowed between digits and after any base specifier. Leading, trailing, or multiple underscores in a row are not allowed.

The string formatting language also now has support for the '_' option to signal the use of an underscore for a thousands separator for floating point presentation types and for integer presentation type 'd'. For integer presentation types 'b', 'o', 'x', and 'X', underscores will be inserted every 4 digits:

>>> '{:_}'.format(1000000)
>>> '{:_x}'.format(0xFFFFFFFF)

See also:

PEP 515 – Underscores in Numeric Literals
PEP written by Georg Brandl and Serhiy Storchaka.


Given a Numpy matrix a containing only integers, return a string representation of the element at the i-th row and j-th column. The string must use underscores as presented before (eg. 123456 must be converted into '123_456').

Literal String Example
def get_element(a, i, j):
el = a.item((i, j))
return el # TODO
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content