Skip to content

Simplify Isotope repr #473

@tjlaboss

Description

@tjlaboss

Let's say we have an O-16 Isotope in the 01c xslib. Currently,

>>> str(o16)
' O-16  (01c)'
>>> repr(o16)
'ZAID=8016, Z=8, A=16, element=oxygen, library=01c'

__repr__ is mostly used for debugging and logging purposes and should remain simple.

Describe the solution you'd like

Move the current __repr__ to __str__, and do the following instead:

>>> repr(o16)
'Isotope(8016.01c)'

Describe alternatives you've considered
I think the Isotope({self.ZAID}) is best, because ZAID is the most widely used convention in MCNP [citation needed]. However, the new MCNP6.3.1 style would be acceptable as well:

>>> repr(o16)
'Isotope(O-16.01c)'

Single or double quotes around the identifier may be preferable as well: Isotope(". . .") or Isotope('. . .')

Additional context
More broadly, the __repr__ functions should be simplified throughout MontePy to be brief and to show the class name. I'm targeting this one first because of #472.

Metadata

Metadata

Assignees

Labels

feature requestAn issue that improves the user interface.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions