![]() |
Class Modules, and Passing Variables: Seeking Advice - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Class Modules, and Passing Variables: Seeking Advice (/thread-8615.html) |
RE: Class Modules, and Passing Variables: Seeking Advice - Robo_Pi - Mar-02-2018 (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. RE: Class Modules, and Passing Variables: Seeking Advice - snippsat - Mar-02-2018 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()] |