replaced magic numbers with macros

This commit is contained in:
Martinez 2015-04-07 13:18:11 +02:00
parent 6da1698762
commit 313a2dee99
2 changed files with 79 additions and 28 deletions

18
256-xterm-colors.py Executable file
View file

@ -0,0 +1,18 @@
#! /usr/bin/env python3
# encoding: utf-8
import sys
def out(text):
sys.stdout.write(text)
if __name__ == '__main__':
for i in range(256):
out('\033[48;5;%dm\033[38;5;15m %03d ' %(i, i))
out('\033[48;5;0m\033[38;5;%dm %03d\t' %(i, i))
if (i + 1) % 8 == 0 if (i + 1) <= 16 else ((i + 1) - 16) % 6 == 0:
out('\n')
if (i + 1) % 16 == 0 if (i + 1) <= 16 else ((i + 1) - 16) % 36 == 0:
out('\n')