[Python-Dev] namedtuples bug between 3.3.2 and 3.4.1
Hi.
I am using Python 3.4.1 installed with Anaconda. I tried the following
(expecting an OrderedDict as result):
>>>from collections import namedtuple
>>>NT = namedtuple("NT",["a","b"])
>>>nt = NT(1,2)
>>>print(vars(nt))
{}
so the result is an empty dict. In Python 3.3.2 (downgraded in the
same Anaconda environment) results in:
>>>print(vars(nt))
OrderedDict([('a', 1), ('b', 2)])
I haven't looked at the source code, I can do that later in the week
and see if I can pinpoint where this is happening. But any suggestions
what and where to fix this would be good :)
Cheers,
Brynjar
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] namedtuples bug between 3.3.2 and 3.4.1
On Sun, Sep 14, 2014 at 8:13 PM, Brynjar Smári Bjarnason
wrote:
> I am using Python 3.4.1 installed with Anaconda. I tried the following
> (expecting an OrderedDict as result):
>
from collections import namedtuple
NT = namedtuple("NT",["a","b"])
nt = NT(1,2)
print(vars(nt))
> {}
>
> so the result is an empty dict. In Python 3.3.2 (downgraded in the
> same Anaconda environment) results in:
>
print(vars(nt))
> OrderedDict([('a', 1), ('b', 2)])
For what it's worth, I can't reproduce the issue on trunk CPython
(built from default branch on Aug 21, so it's a little old now), nor
on 3.4.1 as currently shipping with Debian Jessie, nor with 3.4.0 on
Windows. So this may be an Anaconda issue. Do you know if it's meant
to be a patched install of Python?
ChrisA
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] namedtuples bug between 3.3.2 and 3.4.1
On Mon, 15 Sep 2014 02:13:53 +1000
Chris Angelico wrote:
> On Sun, Sep 14, 2014 at 8:13 PM, Brynjar Smári Bjarnason
> wrote:
> > I am using Python 3.4.1 installed with Anaconda. I tried the following
> > (expecting an OrderedDict as result):
> >
> from collections import namedtuple
> NT = namedtuple("NT",["a","b"])
> nt = NT(1,2)
> print(vars(nt))
> > {}
> >
> > so the result is an empty dict. In Python 3.3.2 (downgraded in the
> > same Anaconda environment) results in:
> >
> print(vars(nt))
> > OrderedDict([('a', 1), ('b', 2)])
>
> For what it's worth, I can't reproduce the issue on trunk CPython
> (built from default branch on Aug 21, so it's a little old now), nor
> on 3.4.1 as currently shipping with Debian Jessie, nor with 3.4.0 on
> Windows. So this may be an Anaconda issue. Do you know if it's meant
> to be a patched install of Python?
There may be a couple distutils-specific patches, but that's all.
Anaconda issues should be reported at
https://github.com/ContinuumIO/anaconda-issues/issues/
Regards
Antoine.
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] List insert at index that is well out of range - behaves like append
I had a list a = [1, 2, 3] when I did a.insert(100, 100) [1, 2, 3, 100] as list was originally of size 4 and I was trying to insert value at index 100 , it behaved like append instead of throwing any errors as I was trying to insert in an index that did not even existed . Should it not throw IndexError: list assignment index out of range exception as it throws when I attempt doing a[100] = 100 Question : 1. Any idea Why has it been designed to silently handle this instead of informing the user with an exception ? Personal Opinion : Lets see how other dynamic languages behave in such a situation : Ruby : > a = [1, 2] > a[100] = 100 > a => [1, 2, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 100] The way ruby handles this is pretty clear and sounds meaningful (and this is how I expected to behave and it behaved as per my expectation) at least to me . So what I felt was either it should throw exception or do the way ruby handles it . Is ruby way of handling not the obvious way ? I even raised it in stackoverflow http://stackoverflow.com/questions/25840177/list-insert-at-index-that-is-well-out-of-range-behaves-like-append and got some responses . ___ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
