1
I made this program in python :
//////////color.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class Color(object):
string = {
"RED": "\x1b[31m",
"GREEN": "\x1b[32m",
"BLUE": "\x1b[34m",
"YELLOW": "\x1b[33m",
"CYAN": "\x1b[36m",
"GREY": "\x1b[38;5;247m",
"ENDC": "\x1b[0m"
}
if use_colors in ["off", "OFF"]:
string = {
"RED": "",
"GREEN": "",
"BLUE": "",
"YELLOW": "",
"CYAN": "",
"GREY": "",
"ENDC": ""
}
//hello.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from color import Color as colors
class HelloWorld(object):
def __init__(self, colors):
print("%s".format
(
self.colors.string["RED"], "Hello ", self.colors.string["ENDC"],
self.colors.string["GREEN"], "World!"],
self.colors.string["ENDC"])
)
but in doing:
$python hello.py
it generates the following error below:
File "hello.py", line 13 self.colors.string["GREEN"], "World!" ], Syntaxerror: invalid syntax
What is the error? Because I tested creating a variable called msg="Hello World"
and gives error too.
I did not understand the negative vote. What Gustavo said is right.
– Oralista de Sistemas
It worked here I ran the program and legal funfou..
– dark777