def lambda_notation(tokens, local_dict, global_dict):
 result = []
 flag = False
 (toknum, tokval) = tokens[0]
 tokLen = len(tokens)
 if ((toknum == NAME) and (tokval == 'lambda')):
  if (tokLen == 2):
   result.extend(tokens)
  elif (tokLen > 2):
   result.extend([(NAME, 'Lambda'), (OP, '('), (OP, '('), (OP, ')'), (OP, ')')])
   for (tokNum, tokVal) in tokens[1:]:
    if ((tokNum == OP) and (tokVal == ':')):
     tokVal = ','
     flag = True
    if ((not flag) and (tokNum == OP) and (tokVal in ['*', '**'])):
     raise TokenError('Starred arguments in lambda not supported')
    if flag:
     result.insert((-1), (tokNum, tokVal))
    else:
     result.insert((-2), (tokNum, tokVal))
 else:
  result.extend(tokens)
 return result

def lambda_notation ( tokens , local_dict , global_dict ) : result = [ ] flag = False ( toknum , tokval ) = tokens [ 0 ] tokLen = len ( tokens ) if ( ( toknum == NAME ) and ( tokval == 'lambda' ) ) : if ( tokLen == 2 ) : result . extend ( tokens ) elif ( tokLen > 2 ) : result . extend ( [ ( NAME , 'Lambda' ) , ( OP , '(' ) , ( OP , '(' ) , ( OP , ')' ) , ( OP , ')' ) ] ) for ( tokNum , tokVal ) in tokens [ 1 : ] : if ( ( tokNum == OP ) and ( tokVal == ':' ) ) : tokVal = ',' flag = True if ( ( not flag ) and ( tokNum == OP ) and ( tokVal in [ '*' , '**' ] ) ) : raise TokenError ( 'Starred arguments in lambda not supported' ) if flag : result . insert ( ( - 1 ) , ( tokNum , tokVal ) ) else : result . insert ( ( - 2 ) , ( tokNum , tokVal ) ) else : result . extend ( tokens ) return result
substitutes "lambda" with its sympy equivalent lambda() .