#!C:/python20/bin/python.exe class Morse: ''' Morseklasse Synopsis: m = Morse() m.str2mrs("Hallo Welt") ''' def __init__(self): ''' Anlegen Klassenbezeichner ''' self.code = "etianmsurwdkgohvfüläpjbxcyzqö" self.sgn = {} self.sgn["ch"] = "----" self.sgn[" "] = " " #Fehlt: Leertaste for i in self.code: self.sgn[i] = self.itob(self.code.find(i)+2) self.sgn[i] = self.sgn[i].replace("0", ".") self.sgn[i] = self.sgn[i].replace("1", "-") self.sgn[i] = self.sgn[i][1:] def itob(self,i, b = ""): ''' Binaerumwandlung ''' while i > 0: b = `i%2` + b i /= 2 return b def str2mrs(self, txt=""): ''' Wandle Text in Morsezeichen um ''' for i in txt.lower(): print self.sgn[i],