Python Forum
Class Modules, and Passing Variables: Seeking Advice
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Class Modules, and Passing Variables: Seeking Advice
#22
Sorry but that code with comment is 21 lines and messy Dodgy
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()]
Reply


Messages In This Thread
RE: Class Modules, and Passing Variables: Seeking Advice - by snippsat - Mar-02-2018, 05:22 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  help seeking for prediction of fixed effect model gotodockforevildragon 1 187 Jun-23-2024, 08:09 AM
Last Post: johnthomson112
  Seeking advice on dask distributed sawtooth500 4 546 Apr-15-2024, 11:07 PM
Last Post: sawtooth500
  Unchangeable variables in a class? Calab 12 1,908 Sep-15-2023, 07:15 PM
Last Post: deanhystad
  Class variables and Multiprocessing(or concurrent.futures.ProcessPoolExecutor) Tomli 5 4,141 Nov-12-2021, 09:55 PM
Last Post: snippsat
  How to pass variables from one class to another hobbyist 18 11,617 Oct-01-2021, 05:54 PM
Last Post: deanhystad
  Acess variables from class samuelbachorik 3 1,996 Aug-20-2021, 02:55 PM
Last Post: deanhystad
  Passing Variables between files. victorTJ 3 2,387 Oct-17-2020, 01:45 AM
Last Post: snippsat
  New user seeking help EdRaponi 2 58,451 Jun-23-2020, 12:03 PM
Last Post: EdRaponi
  Class variables menator01 2 2,124 Jun-04-2020, 04:23 PM
Last Post: Yoriz
  Question about naming variables in class methods sShadowSerpent 1 2,110 Mar-25-2020, 04:51 PM
Last Post: ndc85430

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020