About 524,000 results
Open links in new tab
  1. python - What is __main__.py? - Stack Overflow

    Oct 28, 2010 · $ python my_program.py You can also create a directory or zipfile full of code, and include a __main__.py. Then you can simply name the directory or zipfile on the command …

  2. python - What does if __name__ == "__main__": do? - Stack Overflow

    Jan 7, 2009 · If Python is loading this source code file as the main program (i.e. the file you run), then it sets the special __name__ variable for this file to have a value "__main__".

  3. Why doesn't the main () function run? (What is a Python script's …

    Python runs scripts from top to bottom. def is a statement, and it executes when it is encountered, just like any other statement. However, the effect of this is to create the function (and assign it …

  4. python - Can't open file 'file.py': [Errno 2] No such file or directory ...

    Mar 14, 2020 · I'm using Windows10 and wants to run my python script by cmd The command: python file.py return the message: python: can't open file 'file.py': [Errno 2] No such file or …

  5. python - How to configure __main__.py, __init__.py, and setup.py …

    Package/ setup.py src/ __init__.py __main__.py code.py I want to be able to run the code in a lot of different ways. pip install Package and then python and then from Package import * python …

  6. Understanding the main method of python - Stack Overflow

    $ python using_name.py This program is being run by itself $ python >>> import using_name I am being imported from another module >>> How It Works - Every Python module has it's …

  7. Restart python-script from within itself - Stack Overflow

    Jul 4, 2012 · I have a python-based GTK application that loads several modules. It is run from the (linux) terminal like so: ./myscript.py --some-flag setting From within the program the user can …

  8. What is the difference between __init__.py and __main__.py?

    Jul 10, 2015 · 13 __init__.py, among other things, labels a directory as a python directory and lets you set variables on a package wide level. __main__.py, among other things, is run if you try …

  9. Python: How can I use variable from main file in module?

    Python: How can I use variable from main file in module? Asked 14 years, 6 months ago Modified 3 years, 10 months ago Viewed 26k times

  10. python __main__ and __init__ proper usage - Stack Overflow

    Feb 8, 2016 · Execute the Python code contained in script, which must be a filesystem path (absolute or relative) referring to either a Python file, a directory containing a __main__.py file, …