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 when doing:
$python hello.py
It generates the following error below:
File "hello.py", line 13 self.colors.string ["GREEN"], "World!"] ^ SyntaxError: invalid syntax
What's wrong? Because I tested by creating a variable called msg="Hello World"
and gives error too.