def get_selection(text):
 try:
  first = text.index('sel.first')
  last = text.index('sel.last')
 except TclError:
  first = last = None
 if (not first):
  first = text.index('insert')
 if (not last):
  last = first
 return (first, last)

def get_selection ( text ) : try : first = text . index ( 'sel.first' ) last = text . index ( 'sel.last' ) except TclError : first = last = None if ( not first ) : first = text . index ( 'insert' ) if ( not last ) : last = first return ( first , last )
return tuple of line .