0

I have a problem with using values from my constructor. I'm passing three (input) values for my fuzzy logic which for some reason I can't use. I'm getting an error message: name 'self' is not defined.

I don't know what am I doing wrong since I have a similar class in my code and that works fine? This is just a simple version of my code:

class FirstFuzzy:

    def __init__(self, length, arr, dep):
        self.veh_que = length
        self.veh_arr = arr
        self.veh_dep = dep

    print(self.veh_que)  

1 Answer 1

1

Please shift the print statement inside the constructor. Or create a method inside the class and then try to print that statement.

class FirstFuzzy:

def __init__(self, length, arr, dep):
    self.veh_que = length
    self.veh_arr = arr
    self.veh_dep = dep
    print(...)
Sign up to request clarification or add additional context in comments.

2 Comments

So I can only use these values inside init or another method not outside?
Yes. You cannot reference something outside the scope.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.