From ed1df9f3c1f51752656ca98da5693a4119add05c Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 1 Jun 2021 14:50:33 +0200 Subject: [PATCH] Regexp for evaluated commands --- src/groups.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/groups.py b/src/groups.py index 30e4564..3b359a2 100644 --- a/src/groups.py +++ b/src/groups.py @@ -49,8 +49,8 @@ for group in list(groups.keys()): command_py = command dims_py = str(dims) for g in list(groups.keys()): - command_py = command_py.replace(g,'self.'+g) - dims_py = dims_py.replace(g,'self.'+g) + command_py = re.sub("(\W)"+g, r"\1self."+g, command_py) + dims_py = dims_py.replace("(\W)"+g,r'\1self.'+g) var = var.lower() group = group.lower() strdims = tuple(['('+str(x)+')' for x in dims])