dmesg --follow
[ 68673720.000 ] posts.x: @davidsenra you will love this!  |   [ 68673600.000 ] posts.x: https://t.co/vhJifvV8y9  |   [ 68673600.000 ] posts.x: This Jay-Z documentary, In 8, is exceptional! Nearly 6 hours of intimate conversation between @sc and the brilliant @RickRubin. It’s rare to get such…  |   [ 68662260.000 ] posts.x: Full talk on turning re-prompted fixes into linters, including the OpenAPI drift fix and the skill-writing whack-a-mole:  |   [ 68662260.000 ] posts.x: Re-prompting an agent to fix the same sloppy pattern over and over isn't a workflow, it's a sign the rule should live in code, not in your head…  |   [ 68650020.000 ] posts.x: ↻ @willcb: me: kinda fucked up how many people are offloading their whole lives to muse or instinct or grokbot or whatever claude: yeah  |   [ 68650020.000 ] posts.x: ↻ @iamdevloper: signs you've become the senior dev: you're the only one who understands the deploy script you're the only one who remembe…  |   [ 68649720.000 ] posts.x: Gooooooooood morning! Brazil Oberon Cerrado. Roasted 110 seconds past first crack. Milk chocolate and almond.  |   [ 68647800.000 ] posts.x: @Saanvi_dhillon “Git expert” is a weird flex, though, isn’t it?  |   [ 68610720.000 ] posts.x: @sujee_dev @dkundel @aiDotEngineer Thanks mate!  |   [ 68600580.000 ] posts.x: Full talk on the Codex app server protocol and what you can build on top of the Codex harness:  |   [ 68600580.000 ] posts.x: A lot of engineers assume building their own agent interface means writing their own agent harness from scratch. @dkundel, Developer Experience Lead…  |   [ 68564580.000 ] posts.x: Full talk on why Reducto deleted their all-in-one MCP server and rebuilt it around fewer, state-aware tools and visible agent uncertainty:  |   [ 68564580.000 ] posts.x: A single massive MCP file worked fine as a curated demo and broke the moment Reducto's own team got hold of it. @abhiarya, who works on product…  |  
corey@gallon.me:~/til$

__main__.py file in a project

FIGURE 1 ⋅ __main__.py file in a project

This is, to a Python project / module, what if __name__ == '__main__ is to an individual Python file.

In Python projects, a __main__.py file is used to define what happens when a package or module is run directly as a script. It allows you to make the package executable from the command line, similar to how you would run a single Python script.

Here’s how it works:

  1. Executed when the package is run as a script: When you run a package like this:
python -m package_name

The __main__.py file inside the package is executed, just like a script. This is similar to how a main() function works in other programming languages.

  1. Entry point for a package: It serves as an entry point to the package’s functionality. You can add logic here that should be executed when the package is run.
  2. Example Structure:
my_package/
├── __init__.py
├── __main__.py
├── module1.py
└── module2.py

If you run:

python -m my_package

Python will execute the __main__.py file in my_package.

  1. Typical Use Case: It’s often used to bootstrap or run the application, e.g., starting a server, running an app, or triggering some core functionality when the package is invoked from the command line.

For example, in a __main__.py file, you might have:

def main():
    print("Running the application!")

if __name__ == "__main__":
    main()

This ensures that the package can be run both as a standalone script or imported as a module without accidentally triggering the main execution logic.

corey@gallon.me:~$ tail -f /writing Attach to the stream. An email when I have something worth sending. Replies encouraged!
corey@gallon.me:~$ ls -lt /til ↑2024-10-15 A nice workflow for creating Python projects with AI
▸2024-10-15 __main__.py file in a project ⋅ you are here
↓2024-10-15 neofetch for Linux system info summary