This gives error:
if __name__=="__main__":
box = Myfunc()
box.do(1)
if box.loop() <> Drh.DrhOk:
return
else:
...
...
SyntaxError: 'return' outside function
How do I return if __name__=="__main__":
block?
You don't. Your __main__
block should always read:
if __name__ == "__main__":
main()
Putting your code inside a main()
function ensures that it is testable.
You don't want to return, you probably want to stop the execution. Use sys.exit()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With