И я выбрал вот это — file.py:
Код: Выделить всё
# some code before this.
def open_file():
file_path = input('Type file path (with complete file name): ')
if file_path.endswith('.wav'):
wave_obj = simpleaudio.WaveObject.from_wave_file(file_path)
play_obj = wave_obj.play()
print('File playing...')
else:
print('Unknown file extension.')
Код: Выделить всё
main.py:
# some more code before and after this.
elif input_str == 'file.open':
file.open_file()
while True:
cmd_input = input('>> ').casefold()
cmd_cond_branch(cmd_input)
Процесс завершен с код выхода -1073741819 (0xC0000005)
Но я хочу, чтобы он вернулся в main.py.
Я попытался добавить возврат в конец условной ветки и в конце функции выхода open_file() - file.py:
Код: Выделить всё
# some code before this.
def open_file():
file_path = input('Type file path (with complete file name): ')
if file_path.endswith('.wav'):
wave_obj = simpleaudio.WaveObject.from_wave_file(file_path)
play_obj = wave_obj.play()
print('File playing...')
return
else:
print('Unknown file extension.')
Код: Выделить всё
# some code before this.
def open_file():
file_path = input('Type file path (with complete file name): ')
if file_path.endswith('.wav'):
wave_obj = simpleaudio.WaveObject.from_wave_file(file_path)
play_obj = wave_obj.play()
print('File playing...')
return
else:
print('Unknown file extension.')
return
Код: Выделить всё
# some code before this.
def open_file():
file_path = input('Type file path (with complete file name): ')
if file_path.endswith('.wav'):
wave_obj = simpleaudio.WaveObject.from_wave_file(file_path)
play_obj = wave_obj.play()
print('File playing...')
else:
print('Unknown file extension.')
return
Подробнее здесь: https://stackoverflow.com/questions/783 ... tomaticall