def _chomp(string):
 if (len(string) and (string[(-1)] == '\n')):
  string = string[:(-1)]
 if (len(string) and (string[(-1)] == '\r')):
  string = string[:(-1)]
 return string

def _chomp ( string ) : if ( len ( string ) and ( string [ ( - 1 ) ] == '\n' ) ) : string = string [ : ( - 1 ) ] if ( len ( string ) and ( string [ ( - 1 ) ] == '\r' ) ) : string = string [ : ( - 1 ) ] return string
rather than rstrip() .