diff options
Diffstat (limited to 'Python/pywarpx/Bucket.py')
-rw-r--r-- | Python/pywarpx/Bucket.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Python/pywarpx/Bucket.py b/Python/pywarpx/Bucket.py index b4ae4a06a..3a0d2862c 100644 --- a/Python/pywarpx/Bucket.py +++ b/Python/pywarpx/Bucket.py @@ -50,20 +50,24 @@ class Bucket(object): if value is None: continue # --- repr is applied to value so that for floats, all of the digits are included. - # --- The strip is then needed when value is a string. + # --- The strip of "'" is then needed when value is a string. if isinstance(value, str): - rhs = value + if value.find('=') > -1: + # --- Expressions with temporary variables need to be inside quotes + rhs = f'"{value}"' + else: + rhs = value elif np.iterable(value): if len(value) == 0: # --- Skip if empty continue # --- For lists, tuples, and arrays make a space delimited string of the values. # --- The lambda is needed in case this is a list of strings. - rhs = ' '.join(map(lambda s : repr(s).strip("'\""), value)) + rhs = ' '.join(map(lambda s : repr(s).strip("'"), value)) elif isinstance(value, bool): rhs = 1 if value else 0 else: rhs = value - attrstring = '{0}.{1} = {2}'.format(self.instancename, attr, repr(rhs).strip("'\"")) + attrstring = '{0}.{1} = {2}'.format(self.instancename, attr, repr(rhs).strip("'")) result += [attrstring] return result |