0

I am back with another problem with my program but this time its with Colorama, and Termcolor(Both of which are being used together)

The format I am looking for: Colors Module [LOADED] Please not the word "Loaded" and ONLY that word should be green

The script:

print 'Colors module',"[", cprint("LOADED","green"),"]"

I want to know how I could get it to format the way I am hoping for

Currently the word loaded is green like it should however its the ending ] thats the problem, it is on the next line

Colors module [LOADED
 None ]

Does anyone know how to fix this? (PS if you recommend another module instead of those to, I am using python version 2.7)

Cœur
  • 37,241
  • 25
  • 195
  • 267
NaruS
  • 168
  • 1
  • 15
  • 1
    Why do you use `cprint` when Colorama already can inject color into your print statement? – Jongware Jan 31 '18 at 19:01
  • Because I use termcolor along side of Colorama. I am used to this method of doing things. – NaruS Jan 31 '18 at 19:08
  • why do you need termcolor and colorama? – WhatsThePoint Feb 02 '18 at 11:57
  • I cant remember fully, however its mostly due to compatibility or something.I found the use of the two together in the way I use it here on stack overflow, I can find the page to show you. Its explained better here: https://stackoverflow.com/questions/21858567/why-does-termcolor-output-control-characters-instead-of-colored-text-in-the-wind – NaruS Feb 05 '18 at 17:17

1 Answers1

1

The reason you're getting a line break is because the cprint call gives you one. I'm not sure what you need colorama for, the following works for me, albeit in python 3 (which you should be using):

from termcolor import colored
print("Colors module [" + colored("LOADED", "green") + "]")

enter image description here

JosefAssad
  • 4,018
  • 28
  • 37
  • 1
    Well then, I forgot I asked this question, I ended up forgetting I asked this and figured it out myself, however because you went through the effort, have a nice check mark :) – NaruS Dec 18 '19 at 10:49