Skip to content

Script block in __init__.py #1401

@gribok

Description

@gribok

Hi all,

I am trying to understand the following statement in __init__.py

if __name__ == '__main__': # pragma: no cover
from pygments.cmdline import main
sys.exit(main(sys.argv))

As I understood, the mentioned lines should never be executable. An __init__.py declares directory as a package und could provide functions on top-level.
But is it possible to execute __init__.py as script, like per __main__.py?

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions