Skip to content

You can use packages (which provide relative imports) to avoid naming conflicts #1

@RGBCube

Description

@RGBCube

It's a better way, as your program will work when you aren't in the root dir when calling it

For example our file tree looks like this:

arson/
  __init__.py
  __main__.py
  builtins.py

(the init file is needed for it to be a package)

You can import builtins.py from main by adding this to __main__.py:

from . import builtins

print(123)

and you can run your code by running python -m arson where arson is the package directory, this will print 123

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions