self.body.analyse_control_flow(env)
def analyse_declarations(self, env):
- self.condition.analyse_declarations(env)
self.body.analyse_declarations(env)
def analyse_expressions(self, env):
"""
return [x*2 for x in l if x % 2 == 0]
+def listcomp_as_condition(sequence):
+ """
+ >>> listcomp_as_condition(['a', 'b', '+'])
+ True
+ >>> listcomp_as_condition('ab+')
+ True
+ >>> listcomp_as_condition('abc')
+ False
+ """
+ if [1 for c in sequence if c in '+-*/<=>!%&|([^~,']:
+ return True
+ return False
+
def set_comp():
"""
>>> sorted(set_comp())
"""
result = [[a-1 for a in range(b)] for b in range(4)]
return result
+
+def listcomp_as_condition(sequence):
+ """
+ >>> listcomp_as_condition(['a', 'b', '+'])
+ True
+ >>> listcomp_as_condition('ab+')
+ True
+ >>> listcomp_as_condition('abc')
+ False
+ """
+ if [1 for c in sequence if c in '+-*/<=>!%&|([^~,']:
+ return True
+ return False