Skip to content

Comments

Access prompt.txt via consistent path#30

Open
tomviner wants to merge 1 commit intobiobootloader:mainfrom
tomviner:relative-path
Open

Access prompt.txt via consistent path#30
tomviner wants to merge 1 commit intobiobootloader:mainfrom
tomviner:relative-path

Conversation

@tomviner
Copy link

Imagine this folder structure:

$ tree
.
├── project
│   └── script.py
└── wolverine
    └── wolverine.py

I'd like to run wolverine.py from within my project folder. But I get:

$ python /tmp/wolverine/wolverine.py script.py
Traceback (most recent call last):
  File "/tmp/wolverine/wolverine.py", line 20, in <module>
    with open("prompt.txt") as f:
         ^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'prompt.txt'

The fix is to calculate the path to prompt.txt relative to wolverine.py.

The allows running in the following way.

cd project
python ../wolverine/wolverine.py script.py

@tomviner tomviner changed the title Access prompt.txt via relative path Access prompt.txt via consistent path Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant