[Tutor] A Multiple Concatenation Problem

Stephen P. Molnar s.molnar at sbcglobal.net
Sun Sep 20 07:37:30 EDT 2020



On 09/19/2020 09:19 PM, Mats Wichmann wrote:
> On 9/19/20 5:59 PM, Alan Gauld via Tutor wrote:
>> On 19/09/2020 23:26, Stephen P. Molnar wrote:
>>
>>> 2-Phloroeckol.1.log
>> ...
>>> 2-Phloroeckol.9.log
>>> 2-Phloroeckol.10.log
>>> 7-Phloroeckol.1.log
>>> 7-Phloroeckol.2.log
>> ...> 7-Phloroeckol.10.log
>>> Aloeemodin.1.log
>>> Aloeemodin.2.log
>>> <...cut...>
>>> Vescalagin.10.log
>>> .1.log    |
>>> .2.log    |
>>> .3.log    |
>>> .4.log    |
>>> .5.log    |     <-- not sure where these came from, but the rest is
>>> exactly what I wannted.
>>
>> It suggests you have an empty line at the end of your file.
>> If you don;t like these simply add a check that ligand
>> is not "" before creating the filename.
>>
>>      if ligand:
>>         for suf in range(1, 11):
>>             filename = f"{ligand[:-1]}.{suf}.log"
>>
>> Blank lines in the input will then be ignored.
>>
> all of this is part of the general topic of validating your inputs: if
> you're getting stuff from a file something else had generated, you
> shouldn't just blindly proceed on the basis it's all correct and in the
> format you expect: "Trust, but Verify"  :)
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
Very, very good advise!

You really can teach an old dog new tricks.

-- 
Stephen P. Molnar, Ph.D.
www.molecular-modeling.net
614.312.7528 (c)
Skype:  smolnar1



More information about the Tutor mailing list