About 17,800,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 line, and …

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

    Jan 7, 2009 · If you are trying to close a question where someone should be using this idiom and isn't, consider closing as a duplicate of Why is Python running my module when I import it, and how do I …

  3. How to configure __main__.py, __init__.py, and setup.py for a basic ...

    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 -m …

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

    Jul 10, 2015 · __init__.py is run when you import a package into a running python program. For instance, import idlelib within a program, runs idlelib/__init__.py, which does not do anything as its …

  5. Difference between "main.py" and "python main.py" in command …

    I would like to understand what is the difference between the two commands python main.py and main.py to run the main.py file in the command prompt; and which to use in what circumstance.

  6. PyCharm не создает файл main.py в новом проекте

    Jul 14, 2023 · По какой-то причине при создании нового проекта в пайчарме файл main.py не создается. Создаются лишь файлы .gitignore да pyvenv и папки .idea, Lib и Scripts. С чем это …

  7. python __main__ and __init__ proper usage - Stack Overflow

    Feb 8, 2016 · Since I'm rather new to python this particular aspect of language still opaque for me. So, assume that my project contains many files with code that does stuff and two "service" files: …

  8. What exactly is main.py in python and how do I use it to create a one ...

    Oct 26, 2020 · After research I found that most people with multiple python scripts have one main.py file that runs all their scripts and they use this to create a standalone .exe.

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

    Don't. Pass it in. Try and keep your code as decoupled as possible: one module should not rely on the inner workings of the other. Instead, try and expose as little as possible. In this way, you'll protect …

  10. How to run Uvicorn FastAPI server as a module from another Python …

    Sep 30, 2022 · I want to run FastAPI server using Uvicorn from A different Python file. uvicornmodule/main.py import uvicorn import webbrowser from fastapi import FastAPI from …