(Mar-02-2018, 02:33 PM)buran Wrote: [ -> ]concise code is always better and much easier to follow :-)
That all depends on who's trying to read it.
I can't imagine any programmer who would find my coding style difficult to read. To the contrary, a raw beginner should be able to follow my code. And that's what I want.
Sorry but that code with comment is 21 lines and messy
It's just reading a file into a list,the 3 lines from @Grib do the same in a much nicer way.
Just to make it clear,commenting when not needed can make code less readable.
range(0,len(words_raw)):
is not good
Never use "for i in range(len(sequence))
If need comments,try to use doc string.
def read(self, file_path):
'''Read a file to a list and split on new lines(removed)'''
with open(file_path) as stream_reader:
return [line.strip() for line in stream_reader if line.strip()]