-1

I have a python tile menu script where a subprocess executes a bash shell:

    # excute shell script
    subprocess.call([self.path + '/pimenu.sh'] + actions)

and in the shell I have:

   python ./to/file/name/"$*".py

but when the python script which is found and executed returns an error as it cant find the folder with the images in.:

  pygame.error: Couldn't open ./file/name/image.jpg

I am assuming it is looking in the folder the menu script is in, how can I give python or bash the correct path to the scripts resources?

pythonhunter
  • 1,047
  • 3
  • 10
  • 23

1 Answers1

0

You can use a path finding built in python's os package into the scripts ./to/file/name/"$*".py like this:

import os
print os.getcwd()

It is good enought described into the next SO answer: https://stackoverflow.com/a/3430395/2261861

Community
  • 1
  • 1
Max Vyaznikov
  • 4,135
  • 2
  • 11
  • 10