def compound_statements(logical_line):
 line = logical_line
 last_char = (len(line) - 1)
 found = line.find(':')
 while ((-1) < found < last_char):
  before = line[:found]
  if ((before.count('{') <= before.count('}')) and (before.count('[') <= before.count(']')) and (before.count('(') <= before.count(')'))):
   lambda_kw = LAMBDA_REGEX.search(before)
   if lambda_kw:
    before = line[:lambda_kw.start()].rstrip()
    if ((before[(-1):] == '=') and isidentifier(before[:(-1)].strip())):
     (yield (0, 'E731 do not assign a lambda expression, use a def'))
    break
   if before.startswith('def '):
    (yield (0, 'E704 multiple statements on one line (def)'))
   else:
    (yield (found, 'E701 multiple statements on one line (colon)'))
  found = line.find(':', (found + 1))
 found = line.find(';')
 while ((-1) < found):
  if (found < last_char):
   (yield (found, 'E702 multiple statements on one line (semicolon)'))
  else:
   (yield (found, 'E703 statement ends with a semicolon'))
  found = line.find(';', (found + 1))

def compound_statements ( logical_line ) : line = logical_line last_char = ( len ( line ) - 1 ) found = line . find ( ':' ) while ( ( - 1 ) < found < last_char ) : before = line [ : found ] if ( ( before . count ( '{' ) <= before . count ( '}' ) ) and ( before . count ( '[' ) <= before . count ( ']' ) ) and ( before . count ( '(' ) <= before . count ( ')' ) ) ) : lambda_kw = LAMBDA_REGEX . search ( before ) if lambda_kw : before = line [ : lambda_kw . start ( ) ] . rstrip ( ) if ( ( before [ ( - 1 ) : ] == '=' ) and isidentifier ( before [ : ( - 1 ) ] . strip ( ) ) ) : ( yield ( 0 , 'E731 do not assign a lambda expression, use a def' ) ) break if before . startswith ( 'def ' ) : ( yield ( 0 , 'E704 multiple statements on one line (def)' ) ) else : ( yield ( found , 'E701 multiple statements on one line (colon)' ) ) found = line . find ( ':' , ( found + 1 ) ) found = line . find ( ';' ) while ( ( - 1 ) < found ) : if ( found < last_char ) : ( yield ( found , 'E702 multiple statements on one line (semicolon)' ) ) else : ( yield ( found , 'E703 statement ends with a semicolon' ) ) found = line . find ( ';' , ( found + 1 ) )
compound statements are generally discouraged .