restore pylammps.py

This commit is contained in:
Axel Kohlmeyer
2025-06-20 14:42:52 -04:00
parent b036c911e7
commit 8dff25296b

View File

@ -16,6 +16,10 @@
# Written by Richard Berger <richard.berger@outlook.com>
################################################################################
# for python2/3 compatibility
from __future__ import print_function
import io
import os
import re
@ -758,7 +762,7 @@ class PyLammps(object):
if self.comm_me > 0:
raise Exception("PyLammps.eval() may only be used on MPI rank 0")
value = print('"$(%s)"' % expr).strip()
value = self.lmp_print('"$(%s)"' % expr).strip()
try:
return float(value)
except ValueError:
@ -843,6 +847,10 @@ class PyLammps(object):
elements.append(element)
return elements
def lmp_print(self, s):
""" needed for Python2 compatibility, since print is a reserved keyword """
return self.__getattr__("print")(s)
def __dir__(self):
return sorted(set(['angle_coeff', 'angle_style', 'atom_modify', 'atom_style', 'atom_style',
'bond_coeff', 'bond_style', 'boundary', 'change_box', 'communicate', 'compute',