Skip to content

Commit

Permalink
Merge pull request #175 from TheoChem-VU/174-issue-with-writing-molec…
Browse files Browse the repository at this point in the history
…ules-when-the-molecule-does-not-have-a-comment-variable

Now checking if the molecule has a comment attribute or not
  • Loading branch information
YHordijk authored Mar 18, 2024
2 parents 6232c2b + d1ba15c commit 0c04ee7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/tcutility/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def save(mol: plams.Molecule, path: str, comment: str = None):
"""Save a molecule in a custom xyz file format.
Molecule and atom flags can be provided as the "flags" parameter of the object (mol.flags and atom.flags).
"""
comment = comment or mol.comment
comment = comment or mol.comment if hasattr(mol, 'comment') else ''
with open(path, "w+") as f:
f.write(f"{len(mol.atoms)}\n{comment}\n")
for atom in mol.atoms:
Expand Down

0 comments on commit 0c04ee7

Please sign in to comment.