def print_statement(self): self.humanoid_print('print(' + random.choice([ Generators.get_statement(), Generators.generate_number(), Generators.generate_function_name(), Generators.generate_variable_name() ]) + ')') self.followup = False
def except_statement(self): if random.randint(0, 1) is 0: self.humanoid_print('except:', matching_indent=True) else: self.humanoid_print('except ' + Generators.generate_exception() + ' as e:', matching_indent=True) self.tab = self.tab + 1 self.followup = True
def if_inline_statement(self): self.humanoid_print(Generators.generate_variable_name() + ' = ' + Generators.generate_value() + ' if (' + Generators.get_statement() + ') else ' + Generators.generate_value()) self.followup = False
def if_statement(self): self.humanoid_print('if ' + Generators.get_statement() + ':') self.tab = self.tab + 1 self.followup = True
def comment_statement(self): comment = Generators.generate_comment() self.humanoid_print(comment)
def execute_function_statement(self): self.humanoid_print(Generators.generate_function_name()) self.followup = False
def assign_var_value(self): random_var = Generators.generate_variable_name() output = random_var + ' = ' + Generators.generate_value() self.humanoid_print(output) self.followup = False
def create_function(self): self.humanoid_print('def ' + Generators.generate_function_name() + ':') self.tab = self.tab + 1 self.followup = True
def create_loop(self): loop = Generators.generate_loop() self.humanoid_print(loop) self.tab = self.tab + 1 self.followup = True