Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python: Undefined variable: __init__ error [closed]

Tags:

python

eclipse

I'm trying to write a dummy program with python using eclipse and I get the error message: Undefined variable: __init__.

My aim is to Run the program with eclipse 'Run as' --> Python Run.

When I remove the code:

if __init__=='__main__': 
     main()

and run it from the command line say_something() - it works ok. Any idea what am I doing wrong?

enter image description here

like image 603
adhg Avatar asked Dec 18 '25 07:12

adhg


1 Answers

I think you're looking for if __name__ == '__main__':

like image 158
mayhewr Avatar answered Dec 19 '25 22:12

mayhewr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!