I am using Python 3 through Jupyter Notebook I have two modules "color.py" and "painting.ipynb" in the same working directory.
color.py
from enum import Enum
class Color(Enum):
RED = 1
BLUE = 2
def painting(color):
if color == Color.RED:
print("The painting is red")
elif color == Color.BLUE:
print("The painting is blue")
else:
raise ValueError("The painting is not blue nor red!")
painting.ipynb
import color
color.painting(Color.RED)
When I try to run "painting.ipynb" in jupyter notebook, I have the following error.
--------------------------------------------------------------------------- NameError Traceback (most recent call last) in () 1 import color 2 ----> 3 color.painting(Color.RED)
NameError: name 'Color' is not defined
I do not understand why I cannot access the color. Am I supposed to call the class ? It is the first time that I use jupyter notebook and Enum. Please help :) Thank you.