while i doing my python programming came across an error. code is given below.
import skfuzzy as fuzz
from skfuzzy import control as ctrl
f =fuzzy_()
print(f)
class fuzzy_:
def __init__(self):
pass
def values(self,t = None, m = None, p = None):
"the class name fuzzy_is not defined". Error shown.
Please help.
You need to reorder it like this:
import skfuzzy as fuzz
from skfuzzy import control as ctrl
class fuzzy_:
def __init__(self):
pass
def values(self,t = None, m = None, p = None):
# First define the class
# Then instantiate it
f = fuzzy_()
print(f)
The python interpreter needs to find the class definition first while reading in the code from top-down. In your code example, the interpreter tried instantiating fuzzy_
class object, but threw error as till then it had no idea of what fuzzy_()
is.
python interpreter reads from top to bottom, you are calling the instance of class before defining the class, move line 3 and 4 to the bottom after declaring the class and it should be fine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.