0

I declared a function called load_words above init() to load in the words. However, when I call my function in init(), it gives the error name 'load_words' is undefined at the lines where I call load_words() in init(). Am I not calling my function correctly, or is it a problem with the placement of my function? Thanks in advance.

// edited code out per academic honesty
1

Based on how you write that, I assume both load_words and __init__ to be methods.

As you made load_words a method, you'd have to call it like self.load_words instead of just load_words.

4
  • Thank you so much! Mar 22 '17 at 13:37
  • As the function is not instance-specific, not even class-specific, I'd make make it a regular function rather than a method.
    – Blauelf
    Mar 22 '17 at 14:37
  • As in a function defined outside of the class? Mar 22 '17 at 14:49
  • yes, and without the parameter "self".
    – Blauelf
    Mar 22 '17 at 15:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .