[issue26829] update docs: when creating classes a new dict is created for the final class object

2016-06-02 Thread R. David Murray

R. David Murray added the comment:

Thanks, Emily.

--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue26829] update docs: when creating classes a new dict is created for the final class object

2016-06-02 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 754118f8b3ce by R David Murray in branch '3.5':
#26829: Clarify that namespace is copied to a new __dict__ in instance creation.
https://hg.python.org/cpython/rev/754118f8b3ce

New changeset 5a4ace14b350 by R David Murray in branch 'default':
Merge: #26829: Clarify that namespace is copied to a new __dict__ in instance 
creation.
https://hg.python.org/cpython/rev/5a4ace14b350

--
nosy: +python-dev

___
Python tracker 

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



[issue26829] update docs: when creating classes a new dict is created for the final class object

2016-06-02 Thread Emily Morehouse

Emily Morehouse added the comment:

Trimmed down by keeping the more explicit explanation and taking into account 
suggestions.

--
Added file: http://bugs.python.org/file43127/26829-v3.patch

___
Python tracker 

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



[issue26829] update docs: when creating classes a new dict is created for the final class object

2016-06-02 Thread R. David Murray

R. David Murray added the comment:

I can't get the rietveld review tool to work from this network, so I'll do this 
in a comment.  This looks pretty good to me, but in the following:

  +It is important to note that during the creation of the class, a copy of the
  +namespace object is used in the final class object and the original namespace
  +object is discarded. More explicitly, this means that when ``type.__new__`` 
is
  +called, the object provided as the namespace parameter has its contents 
copied
  +to a standard Python dictionary.

I think it is more in keeping with the style of the rest of the doc to boil 
this down as much as possible.  We can drop the "It is important to note that", 
and just state the issue once, using the "more explicit" version.  I think 
borrowing your revised language from the type docs would work well here, by 
adding "which becomes the __dict__ of the class object" to the end of that 
sentence.

--

___
Python tracker 

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



[issue26829] update docs: when creating classes a new dict is created for the final class object

2016-06-02 Thread Emily Morehouse

Emily Morehouse added the comment:

Second version of patch for this -- more clearly states the process and outcome 
for class creation. Also adds to 
https://docs.python.org/3.6/library/functions.html#type to clarify that the 
dictionary object is copied to a standard dict.

--
Added file: http://bugs.python.org/file43122/26829-v2.patch

___
Python tracker 

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



[issue26829] update docs: when creating classes a new dict is created for the final class object

2016-06-02 Thread R. David Murray

R. David Murray added the comment:

Your suggested wording isn't correct, I'm afraid.  This subject is complex and 
somewhat obscure...I checked with Ethan to make sure my interpretation was 
correct.  The problem this issue is addressing is the fact that when 
type.__new__ is called (as in the metaclass example), whatever is passed in as 
the namespace has its *contents* copied into a new, standard python dict, and 
the original namespace object is discarded.  The metaclass example does this 
explicitly (by doing dict(namespace), but in fact type.__new__ does it 
implicitly (which IMO makes that example a bit confusing).

Also, that namespace is the only state.  The metaclass example obscures that by 
doing an attribute assignment after calling type.__new__, but that attribute 
assignment is actually updating the __dict__ of the new object ('result'), 
which is that new python dict containing the contents of namespace.

--
nosy: +r.david.murray

___
Python tracker 

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



[issue26829] update docs: when creating classes a new dict is created for the final class object

2016-06-02 Thread Emily Morehouse

Emily Morehouse added the comment:

Super straight-forward -- this simply adds to the docs on creating the class 
object that the values used in creation are copied to the final object 
(including the namespace).

--
keywords: +patch
nosy: +emilyemorehouse
Added file: http://bugs.python.org/file43112/26829.patch

___
Python tracker 

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



[issue26829] update docs: when creating classes a new dict is created for the final class object

2016-04-22 Thread Ethan Furman

New submission from Ethan Furman:

https://docs.python.org/3/reference/datamodel.html#creating-the-class-object

This section should mention that the final class is created with a new dict(), 
and all key/value pairs from the dict used during creation are copied over.

--
assignee: docs@python
components: Documentation
messages: 264016
nosy: docs@python, ethan.furman
priority: normal
severity: normal
status: open
title: update docs: when creating classes a new dict is created for the final 
class object
versions: Python 3.4, Python 3.5, Python 3.6

___
Python tracker 

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