flake8-simplify icon indicating copy to clipboard operation
flake8-simplify copied to clipboard

[New Rule] Underscores in Numeric Literals

Open zephvr opened this issue 1 year ago • 1 comments

Explanation

Using underscore on large number make for better comprehension.

This feature was introduced with python 3.6 and PEP515 describe it.

Example

# Bad
amount = 10000000.0
addr = 0xCAFEF00D
flags = 0b0011111101001110
flags = int('0b11110000', 2)

# Good
amount = 10_000_000.0
addr = 0xCAFE_F00D
flags = 0b_0011_1111_0100_1110
flags = int('0b_1111_0000', 2)

zephvr avatar Aug 23 '22 15:08 zephvr