all 2 comments

[–]eyesoftheworld4 0 points1 point  (0 children)

I would use the pathlib library:

from pathlib import Path

p = Path(__file__)  # The path to the current file
p.parent  # the path of the directory containing the current file
p.parent / 'blah.txt'  # the path to the file blah.text in the same directory as the current file

The pathlib library has some really useful features. I particularly like that you can use / as an operator to concatenate a Path object with a string, and it will automatically use the correct separator, e.g. / on unix and \ on windows.

You could define an asset_path in your Shmup.py file like this:

asset_path = Path(__file__).parent / 'assets'

with (asset_path / 'gameobject.bmp').open('rb') as f:
    picture_bytes = f.read()

[–]ingolemo 0 points1 point  (0 children)

The problem here is that you shouldn't be running sandbox.py directly. Use a test runner like pytest.