zhp098 / pwp-capstones

0 stars 0 forks source link

Put a spaces before and after the '=' when declaring a variable #2

Open jmcrey opened 6 years ago

jmcrey commented 6 years ago
        self.raw_text=text
        self.author=author
        self.average_sentence_length=get_average_sentence_length(text)
        self.prepared_text=prepare_text(text)
        self.word_count_frequency=build_frequency_table(prepare_text(text))
        self.ngram_frequency=build_frequency_table(ngram_creator(prepare_text(text)))

When setting any variable, it is a best practice to put a space before and after the = because it makes the code a bit more readable -- it differentiates the spacing of declaration from the spacing of a function call. So, our code would look like this:

        self.raw_text = text
        self.author = author
        self.average_sentence_length = get_average_sentence_length(text)
        self.prepared_text = prepare_text(text)
        self.word_count_frequency = build_frequency_table(prepare_text(text))
        self.ngram_frequency = build_frequency_table(ngram_creator(prepare_text(text)))

Of course, this is more a matter of style than functionality, which ultimately comes down to preference. So, choose what you prefer; but, this is usually an industry standard.

zhp098 commented 6 years ago

That does look cleaner!