paramak icon indicating copy to clipboard operation
paramak copied to clipboard

Consider using .format() in string compositions

Open GregVernon opened this issue 4 years ago • 1 comments

I've found that Cubit commands are often a little easier to read / more maintainable using the .format() method.

For instance, turn this: https://github.com/ukaea/paramak/blob/7924ab0b20e53b0122f56789734bfb795cd73d38/paramak/parametric_neutronics/make_faceteted_neutronics_model.py#L79-L83

into:

cubit.cmd("unite vol {} with vol {}".format(new_vols, new_vols))

or a three-line statement (still fewer lines than the original):

command = "unite vol {} with vol {}"
command.format(new_vols, new_vols)
cubit.cmd(command)

GregVernon avatar Feb 04 '21 03:02 GregVernon