f = open("morse_table.txt")

morse_table = f.read()
morse_table = dict([(morse[0:1], morse[2:len(morse)]) for morse in morse_table.split("\n")])

f.close()

import inspect, os
common_dir = os.path.dirname(inspect.getfile(inspect.currentframe())) # script directory

f = open(os.path.join(common_dir, "morse_table.txt"))

morse_table = f.read()
morse_table = dict([(morse[0:1], morse[2:len(morse)]) for morse in morse_table.split("\n")])

f.close()

Make morse parser not assume that the current working directory is common/
Make morse parser not assume that the current working directory is common/

- f = open("morse_table.txt")
+ import inspect, os
+ common_dir = os.path.dirname(inspect.getfile(inspect.currentframe())) # script directory
+ 
+ f = open(os.path.join(common_dir, "morse_table.txt"))
  
  morse_table = f.read()
  morse_table = dict([(morse[0:1], morse[2:len(morse)]) for morse in morse_table.split("\n")])
  
  f.close()
  
Make morse parser not assume that the current working directory is common/
## Code Before:
f = open("morse_table.txt")

morse_table = f.read()
morse_table = dict([(morse[0:1], morse[2:len(morse)]) for morse in morse_table.split("\n")])

f.close()

## Instruction:
Make morse parser not assume that the current working directory is common/
## Code After:
import inspect, os
common_dir = os.path.dirname(inspect.getfile(inspect.currentframe())) # script directory

f = open(os.path.join(common_dir, "morse_table.txt"))

morse_table = f.read()
morse_table = dict([(morse[0:1], morse[2:len(morse)]) for morse in morse_table.split("\n")])

f.close()
