[Python Tips] Underscores in Numeric Literals

This is a simple tip but can be very useful to visualize large numbers quickly. This feature requires Python 3.6+.

When expressing large numbers in Python, you are unable to use a comma , separator but you are now able to use an underscore _ to make large numbers more readable.

Example time

Right now my reputation is 95,772,209,949,706.000 when looked at in raw form.

To express this in Python you typically would use.

themarkymark_rep = 95772209949706.000

With python 3.6 you can use underscores in your numeric literals like this

themarkymark_rep = 95_772_209_949_706.000

This doesn't change how your code functions in anyway but does make it easier to visualize the scale of the number.

You can also use this when doing binary numbers such as

flags = 0b_0011_1111_0100_1110

Python Tips Series

X48EJ

Why you should vote me as witness

Witness & Administrator of four full nodes

themarkymark.png

My recent popular posts

STEEM, STEEM Power, Vests, and Steem Dollars. wtf is this shit?
The truth and lies about 25% curation, why what you know is FAKE NEWS
WTF is a hardware wallet, and why should you have one?
GINABOT - The Secret to your Sanity on Steemit
How to calculate post rewards
Use SSH all the time? Time for a big boy SSH Client
How to change your recovery account
How curation rewards work and how to be a kick ass curator
Markdown 101 - How to make kick ass posts on Steemit
Work ON your business, not in your business! - How to succeed as a small business
You are not entitled to an audience, you need to earn it!
How to properly setup SSH Key Authentication - If you are logging into your server with root, you are doing it wrong!
Building a Portable Game Console

H2
H3
H4
Upload from PC
Video gallery
3 columns
2 columns
1 column
8 Comments