Python 3 : NameError: name 'functionName' is not defined
<p>I am new in programming and I have faced a problem for which I can't find an answer... So here it is:</p>

<pre><code>`class MyClass:
    def printsmth():
        print("Hello")
    def main():
        printsmth()
    if __name__ == '__main__':main()`
</code></pre>

<p>I get an error which says : </p>

<pre><code>Traceback (most recent call last):
  File "untitled.py", line 1, in &lt;module&gt;
    class MyClass:
  File "untitled.py", line 6, in MyClass
    if __name__ == '__main__':main()
  File "untitled.py", line 5, in main
    printsmth()
NameError: name 'printsmth' is not defined
</code></pre>

<p>Code included is just an example, but it is the same error that I get on my real code, if for example I would transfer my code from main() to if <strong>name</strong> == '<strong>main</strong>' than it works perfectly. The thing is that I want to relaunch main() method in some parts of the code but I haven't even gone to that because I can't think of a solution to this error:/ Can you help me?</p>

<p>P.S I tried to move main() and if <strong>name</strong> == '<strong>main</strong>' from MyClass and it didn't worked.</p>