[BangPypers] sort query

bhaskar jain bhaskar.jain2002 at gmail.com
Sat Oct 24 10:02:56 CEST 2009


Hello,

  Can sort not modify read-only location.

>>> d
{'a': 1, 'c': 3, 'b': 2}

>>> id(d)
412816

>>> id(d.keys())
404296

>>> type(d.keys())
<type 'list'>

>>> print d.keys().sort()
None


We can so sorted(d.keys()) and it works but was just wondering whether sort
which modifies in-place fails when the location is read-only.

Thanks,
 Bhaskar.


More information about the BangPypers mailing list