periodictable icon indicating copy to clipboard operation
periodictable copied to clipboard

unify `__getitem__`

Open CJ-Wright opened this issue 8 years ago • 1 comments

It might be nice if __getitem__ took in element symbols/names in addition to numbers.

CJ-Wright avatar Dec 13 '17 20:12 CJ-Wright

The trivial implementation, extending the dictionary of elements to contain symbols and names, would break the table iterator. Conceptually, having more keys "in" the dictionary then are returned by iterating through it is unexpected (and therefore bad).

The type signature would be ugly, which is generally a bad sign.

The interface already provides table.Fe, table.symbol('Fe') and getattr(table, 'Fe'), so table['Fe'] is even more redundant. This breaks the Zen of Python: There should be one-- and preferably only one --obvious way to do it.

So, how compelling are the arguments to add it?

pkienzle avatar Dec 14 '17 05:12 pkienzle