This script is also located at:
code.google.com/p/python-stdout-colors/
Download PY!
Tell me what you think, leave a comment.
Runnable from terminal:
chmod +x stdout_colours.py
python stdout_colours.py
Use it in your code like this:
self.soc.write(["printing','a','list'],"red")
self.soc.write("printing a string","green")
self.soc.write({"printing":"dictionary","testing":"fun"},'blue')
self.soc.write(("printing","a","tuple"),'yellow')
Add it to your functions like this:
import stdout_colours
class some_class(object):
def __init__(self):
self.testing="fun"
self.func_me_color="white_on_blue"
self.soc=stdout_colours.stdout_colors()
self.soc.me_him(['ENTER:',__name__],self.func_me_color)
self.soc.write("doing something:","red")
self.do_something()
self.soc.me_him(['EXIT:',__name__],self.func_me_color)
def do_something(self):
self.soc.me(['ENTER:',__name__],self.func_me_color)
self.soc.write("doing something else:","green")
self.do_something_else()
self.soc.me(['EXIT:',__name__],self.func_me_color)
def do_something_else(self):
self.soc.me_him(['ENTER:',__name__],self.func_me_color)
self.soc.write(['testing','is',testing],"yellow")
self.soc.me_him(['EXIT:',__name__],self.func_me_color)
EDIT: I actually like to use this over print when I deal with terminal/console apps. Much easier to tell what is going on when text is scrolling by so fast.
I hope this helps someone. Leave a comment. Enjoy.
No comments:
Post a Comment