def open_new_file(prompt_phrase, extension='', hint=None): """will ask for a file name to be typed by user into the console path to the file can be either relative or absolute. Extension will be appended to the given file name. Return value is the file object. """ if extension != '': if extension[0] != '.': extension = '.' + extension else: extension = '' file_object = None if hint: file_path = path.extend_file_name(hint, extension) file_object = path.create_file_if_does_not_exist(file_path, print_warning=True) while file_object == None: file_path = raw_input(prompt_phrase) file_path = path.extend_file_name(file_path, extension) file_object = path.create_file_if_does_not_exist(file_path, print_warning=True) return file_object
def open_new_file(prompt_phrase, extension = '', hint = None): """will ask for a file name to be typed by user into the console path to the file can be either relative or absolute. Extension will be appended to the given file name. Return value is the file object. """ if extension != '': if extension[0] != '.': extension = '.' + extension else: extension = '' file_object = None if hint: file_path = path.extend_file_name(hint, extension) file_object = path.create_file_if_does_not_exist(file_path, print_warning = True) while file_object is None: file_path = raw_input(prompt_phrase) file_path = path.extend_file_name(file_path, extension) file_object = path.create_file_if_does_not_exist(file_path, print_warning = True) return file_object