def decode_morse(msg, sep='|', mapping=None):
 mapping = (mapping or morse_char)
 word_sep = (2 * sep)
 characterstring = []
 words = msg.strip(word_sep).split(word_sep)
 for word in words:
  letters = word.split(sep)
  chars = [mapping[c] for c in letters]
  word = ''.join(chars)
  characterstring.append(word)
 rv = ' '.join(characterstring)
 return rv

def decode_morse ( msg , sep = '|' , mapping = None ) : mapping = ( mapping or morse_char ) word_sep = ( 2 * sep ) characterstring = [ ] words = msg . strip ( word_sep ) . split ( word_sep ) for word in words : letters = word . split ( sep ) chars = [ mapping [ c ] for c in letters ] word = '' . join ( chars ) characterstring . append ( word ) rv = ' ' . join ( characterstring ) return rv
decodes a morse code with letters separated by sep and words by word_sep into plaintext .