[Tutor] A Multiple Concatenation Problem

Richard Damon Richard at Damon-Family.org
Thu Sep 17 13:49:42 EDT 2020


On 9/17/20 1:39 PM, Stephen P. Molnar wrote:
>
> I have a Computational Chemisry Problem where I generate a large
> number of text files with names differing only in an index in the file
> suffix of the form <ligand>.$i.log.
>
> My problem is how do I go from <ligand> to <ligand>.$i.log where '$i"
> is iterated from 1 to 10. in a subsequent section of the pytho script?
>
> All that Google does is increase my confusion.
>
> Finally, this is not a school assignment, nor do I wish t initiate a
> string of nasty comments/. What I am looking for is a point in the
> appropriate direction.
>
> Thanks in advance
>
Look at the Pathlib module, it can be use to tear apart a file path into
component pieces and put them back again. You would use back string
operations to add the .i to the end of the base name of the file

-- 
Richard Damon



More information about the Tutor mailing list