Hack Forums
[Python] Coloring parts of string with termcolor & colorama - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Coloring parts of string with termcolor & colorama (/showthread.php?tid=5156452)



Coloring parts of string with termcolor & colorama - CocoaNut - Feb 2, 2016

So until now I have been creating variables such as "coloredPrice" to hold colored strings. But it is just so fucking retarded.

Example:
PHP Code

<?php 
print("Sending order of " + coloredBuyAmount + " Bitcoins . . .") 

And this is coloredBuyAmount:
PHP Code

<?php 
coloredBuyAmount 
= colored(str(buyAmount), "yellow", attrs=['bold']) 

That works fine, but I feel like there must be an easier way, I'm just not very experienced with termcolor & colorama.

I would want something like this:
PHP Code

<?php 
cprint
("This color is grey " + colored("but this is green", "green")) 
Which I would want to print this: This color is grey but this is green

But that doesn't work

Very much appreciated!

EDIT im more retarded than i thought. the example code i showed worked