On Monday, May 16, 2022 at 11:27:58 PM UTC+8, Dennis Lee Bieber wrote: > On Mon, 16 May 2022 02:03:26 -0700 (PDT), "hongy...@gmail.com" > <hongy...@gmail.com> declaimed the following: > > > >print(lst) > > Printing higher level structures uses the repr() of the structure and > its contents -- theoretically a form that could be used within code as a > literal.
I tried with the repr() method as follows, but it doesn't give any output: ``` import os,sys import numpy as np from fractions import Fraction import re from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.core import Lattice, Structure, Molecule, IStructure def filepath(file): script_dirname=os.path.dirname(os.path.realpath(__file__)) return (script_dirname + '/' + file) s=IStructure.from_file(filepath('EntryWithCollCode136212.cif')) a = SpacegroupAnalyzer(s) SymOp=a.get_symmetry_operations() b=SymOp[1].affine_matrix.tolist() def strmat(m): if(np.array([m]).ndim==1): return str(Fraction(m)) else: return list(map(lambda L:strmat(L), np.array(m))) lst=[] for i in SymOp: lst.append(i.affine_matrix.tolist()) a=str(strmat(lst)) a=re.sub(r"'","",a) repr(a) ``` > If you want human-readable str() you will need to write your own > output loop to do the formatting of the structure, and explicitly print > each item of the structure. -- https://mail.python.org/mailman/listinfo/python-list