[issue29089] Python 2 dictionary keys described incorrectly

2016-12-27 Thread Xezlec

New submission from Xezlec:

In section 5.5 on the page 
https://docs.python.org/2/tutorial/datastructures.html#dictionaries the 
requirements given for dictionary keys are not correct.

Specifically, it is claimed that only immutable objects (and tuples containing 
only immutable objects) may be used as keys.  This is false, as user-defined 
mutable objects may be used as keys.  I suggest rewording along these lines:

"Only user-defined objects and immutable built-in types may be used as keys.  
Although allowed, it is bad practice to use a mutable user-defined object as a 
key when equality is determined in any way other than identity (the default)."

--
assignee: docs@python
components: Documentation
messages: 284135
nosy: Xezlec, docs@python
priority: normal
severity: normal
status: open
title: Python 2 dictionary keys described incorrectly
versions: Python 2.7

___
Python tracker 
<http://bugs.python.org/issue29089>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29089] dictionary keys described incorrectly in tutorial

2016-12-27 Thread Xezlec

Xezlec added the comment:

> It's the tutorial.  Probably better to just leave it alone.  Precise 
> understanding can come later.

But the problem isn't that it's imprecise.  It's flat-out wrong.  My opinion 
would be that it's always a bad idea to put wrong information in the 
documentation, especially when it's the first Google hit.  It can lead to all 
sorts of confusion and frustration (as it did for me).  Users are likely to 
assume documentation from any official source is the final word.

If precision is the problem, could it be reworded to be more vague?

--

___
Python tracker 
<http://bugs.python.org/issue29089>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29089] dictionary keys described incorrectly in tutorial

2016-12-27 Thread Xezlec

Xezlec added the comment:

> Perhaps the sentence about a tuple pointing to a mutable could be tightened 
> up, though, by saying that if a tuple points to something that can not itself 
> be a dictionary key, then that tuple can not be a dictionary key.

That would be great.  Thank you.

> I feel assuming early part of tutorial as final word bad practice.

Alright.  If that's how both of you feel, then it can't be helped.

But if that's how it is, then maybe it would be a good idea to make the 
tutorial more distinct?  Right now, the only way I can tell Google has landed 
me on a tutorial page as opposed to a reference page is the word "tutorial" in 
the URL and in small print at the very top of the page.  They're styled 
similarly.  I never even realized they were separate things until today (let 
alone that one of them must be read skeptically).

Sorry to take up your time.  Thanks for listening.

--

___
Python tracker 
<http://bugs.python.org/issue29089>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com