Skip to content

Cleanning: wierd `while`construction

Why this line?

I guess this is sufficient (rmk: break is commented)

            try:
                # check if envelope mass fraction is specified, then Case 1
                planet_dict["fenv"]
                self.planet_info = "Case 1 - artificial planet"\
                                    + " (with M_core & f_env)" # use formatting for that (str.format())
# adding a blank line here helps for reading
                # Case 1: artificial planet with fenv & M_core given, need to
                #         calculate the total mass and radius
                self.fenv = planet_dict["fenv"]
                self.core_mass = planet_dict["core_mass"]
                self.Calculate_core_radius() # not PEP8
                self.Calculate_planet_mass() # not PEP8
                self.Calculate_planet_radius() # not PEP8
                # break
# adding a blank line here help for reading
            except KeyError:
                ...
  1. PEP8 suggest that method start with lower case.
  2. instead of adding strings better to use formatting:
self.planete_info = "Case {case_index:d} - {description} ({details})"
self.planete_info.format(case_index=1, 
                         description="artificial planete", 
                         details="with M_core & f_env")