Re: [Numpy-discussion] changing ValueError to KeyError for bad field access

2015-06-12 Thread Phil Hodge
On 06/12/2015 01:46 PM, Allan Haldane wrote: > I think it would be very nice to make access to invalid fields of a > structured array give a KeyError instead of a ValueError. Like: > > >>> a = np.ones(3, dtype=[('a', 'f4'), ('b', 'f4')]) > >>> a['c'] > KeyError: 'c' This will break

Re: [Numpy-discussion] changing ValueError to KeyError for bad field access

2015-06-12 Thread Sturla Molden
On 12/06/15 19:46, Allan Haldane wrote: > >>> a = np.ones(3, dtype=[('a', 'f4'), ('b', 'f4')]) > >>> a['c'] > KeyError: 'c' > Any opinions? Sounds good to me. But it will probably break someones code. Sturla ___ NumPy-Discussion mail

[Numpy-discussion] changing ValueError to KeyError for bad field access

2015-06-12 Thread Allan Haldane
Hi all, I think it would be very nice to make access to invalid fields of a structured array give a KeyError instead of a ValueError. Like: >>> a = np.ones(3, dtype=[('a', 'f4'), ('b', 'f4')]) >>> a['c'] KeyError: 'c' A commit in my PR https://github.com/numpy/numpy/pull/5636 does th