Upgrade to Pro — share decks privately, control downloads, hide ads and more …

import antigravity

import antigravity

Nice python command-line one-liners. Great even for people who don't *do* python.

Brad Montgomery

November 07, 2013
Tweet

More Decks by Brad Montgomery

Other Decks in Programming

Transcript

  1. # Print a random number # from 0, 10 (inclusive)

    import random print(random.randint(1, 10)) Thursday, November 7, 13
  2. # CSV File to JSON:: import csv, json print json.dumps(

    list(csv.reader(open('file.csv'))) ) Thursday, November 7, 13
  3. # UTC to CST conversion! for h in range(0,24): print("{0}

    utc -- {1} cst".format( h, (h+6)%24) ) Thursday, November 7, 13
  4. $ python -c “for h in range(0,24): print("{0} utc --

    {1} cst".format(h, (h +6)%24))” Thursday, November 7, 13
  5. 0 utc -- 6 cst 1 utc -- 7 cst

    2 utc -- 8 cst 3 utc -- 9 cst 4 utc -- 10 cst 5 utc -- 11 cst 6 utc -- 12 cst 7 utc -- 13 cst 8 utc -- 14 cst 9 utc -- 15 cst 10 utc -- 16 cst 11 utc -- 17 cst 12 utc -- 18 cst 13 utc -- 19 cst 14 utc -- 20 cst 15 utc -- 21 cst 16 utc -- 22 cst 17 utc -- 23 cst 18 utc -- 0 cst 19 utc -- 1 cst 20 utc -- 2 cst 21 utc -- 3 cst 22 utc -- 4 cst 23 utc -- 5 cst Thursday, November 7, 13
  6. alias lolutc=“python -c ‘for h in range(0,24): print("{0} utc --

    {1} cst".format(h, (h+6)%24))’” Thursday, November 7, 13