Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider using .format() in string compositions #711

Open
GregVernon opened this issue Feb 4, 2021 · 1 comment
Open

Consider using .format() in string compositions #711

GregVernon opened this issue Feb 4, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@GregVernon
Copy link

GregVernon commented Feb 4, 2021

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

For instance, turn this:

cubit.cmd(
"unite vol " +
" ".join(new_vols) +
" with vol " +
" ".join(new_vols))

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)
@shimwell
Copy link
Collaborator

shimwell commented Feb 4, 2021

Thanks Greg this is a nice suggestion, thanks for taking the time to help out. We certainly appreciate it.

I has make a PR for this improvement, it will be a bit slower to merge than our usual PRs as to test this we need to connect to our Trelis license server and perform local tests.

I'm keen to update this script from its python 2 origins and also keen to run it using the system python instead of that os.system call that I current use which is a bit of a mess

os.system("trelis -batch -nographics make_faceteted_neutronics_model.py \"faceting_tolerance='" +
str(self.faceting_tolerance) + "'\" \"merge_tolerance='" + str(self.merge_tolerance) + "'\"")

@RemDelaporteMathurin RemDelaporteMathurin added the enhancement New feature or request label Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants