lolamontes69

Python/ Colors on term

May 19th, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. def _wrap_with(code):
  2.     def inner(text, bold=False):
  3.         c = code
  4.         if bold:
  5.             c = "1;%s" % c
  6.         return "\033[%sm%s\033[0m" % (c, text)
  7.     return inner
  8.  
  9. red = _wrap_with('31')
  10. green = _wrap_with('32')
  11. yellow = _wrap_with('33')
  12. blue = _wrap_with('34')
  13. magenta = _wrap_with('35')
  14. cyan = _wrap_with('36')
  15. white = _wrap_with('37')
  16.  
  17. """
  18. usage
  19. include the function and the code of the color you will be using
  20.  
  21. red = _wrap_with('31')
  22. blue = _wrap_with('34')
  23. print red('Some text'),"tits",blue('Some more text')
  24.  
  25. """
Advertisement
Add Comment
Please, Sign In to add comment