MolSSI / QCEngine

Quantum chemistry program executor and IO standardizer (QCSchema).
https://molssi.github.io/QCEngine/
BSD 3-Clause "New" or "Revised" License
162 stars 78 forks source link

Code refactoring #429

Open tosemml opened 10 months ago

tosemml commented 10 months ago

Description

These slight code adjustments aim to enhance Pythonic quality by incorporating python str.join

Changelog description

Status

loriab commented 10 months ago

Thanks for the suggestion, but I don't think these are equivalent.

>>> mol_string = ""
>>> for iatom in range(4):
...     mol_string += "He " + str(1.0 * iatom) + " 0.0 0.0\n"
... 
>>> mol_string
'He 0.0 0.0 0.0\nHe 1.0 0.0 0.0\nHe 2.0 0.0 0.0\nHe 3.0 0.0 0.0\n'
>>> 
>>> mol_string2 = " 0.0 0.0\n".join(["He " + str(1.0 * iatom) for iatom in range(4)])
>>> mol_string2
'He 0.0 0.0 0.0\nHe 1.0 0.0 0.0\nHe 2.0 0.0 0.0\nHe 3.0'
tosemml commented 10 months ago

I fixed the bug, thanks for highlighting