pinnwand

bpaste has migrated platforms. We now support self removal of pastes and will automatically import pastes from our old software for the following 2 months (that is, until the end of november 2014).

If you have any pastes you'd like to preserve please visit their URLs and they will be automatically imported with no expiry.

This paste never expires. Pasted by import. View raw.

 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
import time
import sys
from string import lowercase
from random import choice

colors = ("grey", "red", "green", "yellow", "blue", "magenta", "cyan")
attributes = ("bold", "underline", "blink", "reverse")

def rand_col(): return choice(colors)
def rand_on_col(): return "on_" + rand_col()
def rand_attr(): return choice(attributes)

def style(ch, c1=None, c2=None, atr=None):
    if atr: return termcolor.colored(ch, c1(), c2(), attrs=[atr()])
    elif c2: return termcolor.colored(ch, c1(), c2())
    elif c1: return termcolor.colored(ch, c1())
    else: return ch

states = { 0: (rand_col, rand_on_col, rand_attr),
           1: (rand_col, rand_col),
           2: (rand_col, ), }

for _ in range(100):
    print style(choice(lowercase), *choice(states))
    sys.stdout.flush()
    time.sleep(0.3)