Hello Michael,
Thanks for the list example. I'll probably do something like that. I still have
to study comprehension.
John
On Fri, Dec 18, 2020 at 07:46:19AM +0000, Michael Whapples wrote:
Hello,
I left out the docstring to keep the email short and as it has little to do
with the functioning of the code. Of course you can add it back in and that
may be a good plan.
The "with" statements are much clearer than the associated
try/except/finally blocks would be for similar reliability of closing the
files. The for iteration of the lines I think is clearer than a while loop
with an if and break. However its your code so do what you think you
understand more.
As for joining many strings, I think using a list and then the str.join
method is the way to go.
str_list = []
str_list.append("First line")
str_list.append("Second line")
long_string = "\n".join(str_list)
I believe this may be even quicker if it can be done with a list
comprehension.
Michael Whapples
On 18/12/2020 03:30, John J. Boyer wrote:
Hello Michael,For a description of the software, to download it and links to
Thanks for the suggestions. However, I felt the program was much easier to
understand as I wrote it, without so many Pyth-y features.
I also wanted to make it self-contained with a doc string at the beginning.
Now I'm trying to find a way to combine many short strings which are lines
from the input file into a long string that approximates a paragraph.
This would be passed to translateString to produce a more readable outpout.
The hard part is to do this efficiently, without a lot of garbage
collection.
John
project pages go to http://liblouis.org
Donate: http://liblouis.org/sponsoring