def parse_constantlike(environment, parser):
 expr = parser.parse_expression()
 if isinstance(expr, Name):
  return expr.name
 try:
  return expr.as_const(EvalContext(environment))
 except Impossible:
  raise NonConstant((u'Not constant: %r' % expr))

def parse_constantlike ( environment , parser ) : expr = parser . parse_expression ( ) if isinstance ( expr , Name ) : return expr . name try : return expr . as_const ( EvalContext ( environment ) ) except Impossible : raise NonConstant ( ( u'Not constant: %r' % expr ) )
parse the next expression as a "constantlike" expression .