one of the first modules I’m working on in a python program I’m putting together is a journal.
I’m getting comfortable using the print function, but for this project it would be great if i Could differentiate some of the text output from others. For example, here’s a text output sample from the program:
November_29_2017 Log_1 11/29/17-Completed Homework Log_2 11/29/17-Did 30min of Cardio
In that sample, November_29_2017 is a printed dictionary label. What I would like to do is have that output in a different color instead of the standard output color, so that way I can differentiate it as a label or headline in my journal.
I don’t know the exact magnitude of this task, but if I could at least be provided with some research materials, I’d be more than willing and appreciative to get this going. Thank you!
Recently I utilized ANSI escape codes to get the color on my print-outs, but this method is limited for me, because it seems to only work with string literals, and not printable objects like list and dictionaries. For example, here is an ANSI escape code to color a string literal:
print '\033[1;34mBlue like Blood\033[1;m'
The output would be the string "Blue like blood" colored blue. But, what if I had a list:
L=["Blue like Blood","Orange bananas and red monkeys."]
Now, it would be time consuming typing all the text in the list object directly into the function and passing it, what would be better is if I could pass the list object through the function using it's index(or key if it's a dict object).
I'm still a rookie in Python, but I believe I know enough that simply trying to slap a list or dict call between an escape code isn't going to work(I tried it).
What I think I need is a method for print() that automatically colors the text of any object passed through the function, like I said, I'm a rookie but I believe it would look something like this:
Terms like: Mapping, "create callable objects", classes,etc., I don't get yet but...well I really don't know but I feel like I'm close. Please, still looking for info, and thanks to the people that have provided input.