Welcome, guest | Sign In | My Account | Store | Cart

This python code generates no lint errors and just print out a few numbers.

Useful if you use the Spyder IDE for the first time, which provides NOTHING to get you started.

Python, 28 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# -*- coding: utf-8 -*-
"""
Created  2015
"""

from decimal import Decimal


# TTT uppercase makes it a list var

# this just demonstrates the normalize-function
# and will print some numbers in a loop
# the Spyder IDE will run it no problem.

def eng(num):
    """ some doc string right here  """
    return Decimal(num).normalize().to_eng_string()

if __name__ == '__main__':

    TTT = [-78951, -500, 1e-3, 0.005, 0.05, 0.12,
               10, 23.3456789, 50, 150, 250, 800, 1250,
               127e11, 51234562]

    for x in TTT:
        print "%s: %s " % (x, eng(x))

###   no lint errors in here

This is one of very few code pieces on this site that actually work copy+paste. How very odd.

1 comment

mai3a (author) 6 years, 2 months ago  # | flag

maybe add a cr/lf at the end which was cut from my original. What a disgrace.