Skip to content

Commit

Permalink
py 3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
earonesty committed Nov 22, 2019
1 parent f4890e4 commit 606277e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions smx/smx.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,17 @@ def define(self, name, body, *args):
j_names = ','.join(args)
defs = ""
for arg in args:
defs += f" self._Smx__locals['{arg}']={arg}\n"
code = f"""
def _tmp(self, {j_names}):
self.push_local({{}})
{defs}
self.__res = self.expand('''{body}''')
defs += " self._Smx__locals['" + arg + "']=" + arg + "\n"
code = """def _tmp(self, """ + j_names + """):
self.push_local({})
""" + defs + """
self.__res = self.expand('''""" + body + """''')
self.pop_local()
return self.__res
"""
locs = {}
exec(code, globals(), locs)
self.__globals[name]=lambda *args: locs["_tmp"](self, *args)
self.__globals[name] = lambda *args: locs["_tmp"](self, *args)

def pop_local(self):
if self.__stack:
Expand Down

0 comments on commit 606277e

Please sign in to comment.