mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 19:34:08 +00:00 
			
		
		
		
	#26829: Clarify that namespace is copied to a new __dict__ in instance creation.
Patch by Emily Morehouse.
This commit is contained in:
		
							parent
							
								
									a32c738ad7
								
							
						
					
					
						commit
						dd4fcf52f4
					
				
					 3 changed files with 9 additions and 2 deletions
				
			
		| 
						 | 
					@ -1449,8 +1449,9 @@ are always available.  They are listed here in alphabetical order.
 | 
				
			||||||
   class name and becomes the :attr:`~class.__name__` attribute; the *bases*
 | 
					   class name and becomes the :attr:`~class.__name__` attribute; the *bases*
 | 
				
			||||||
   tuple itemizes the base classes and becomes the :attr:`~class.__bases__`
 | 
					   tuple itemizes the base classes and becomes the :attr:`~class.__bases__`
 | 
				
			||||||
   attribute; and the *dict* dictionary is the namespace containing definitions
 | 
					   attribute; and the *dict* dictionary is the namespace containing definitions
 | 
				
			||||||
   for class body and becomes the :attr:`~object.__dict__` attribute.  For
 | 
					   for class body and is copied to a standard dictionary to become the
 | 
				
			||||||
   example, the following two statements create identical :class:`type` objects:
 | 
					   :attr:`~object.__dict__` attribute.  For example, the following two
 | 
				
			||||||
 | 
					   statements create identical :class:`type` objects:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      >>> class X:
 | 
					      >>> class X:
 | 
				
			||||||
      ...     a = 1
 | 
					      ...     a = 1
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1734,6 +1734,11 @@ After the class object is created, it is passed to the class decorators
 | 
				
			||||||
included in the class definition (if any) and the resulting object is bound
 | 
					included in the class definition (if any) and the resulting object is bound
 | 
				
			||||||
in the local namespace as the defined class.
 | 
					in the local namespace as the defined class.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					When a new class is created by ``type.__new__``, the object provided as the
 | 
				
			||||||
 | 
					namespace parameter is copied to a standard Python dictionary and the original
 | 
				
			||||||
 | 
					object is discarded. The new copy becomes the :attr:`~object.__dict__` attribute
 | 
				
			||||||
 | 
					of the class object.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.. seealso::
 | 
					.. seealso::
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   :pep:`3135` - New super
 | 
					   :pep:`3135` - New super
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -999,6 +999,7 @@ Peter Moody
 | 
				
			||||||
Paul Moore
 | 
					Paul Moore
 | 
				
			||||||
Ross Moore
 | 
					Ross Moore
 | 
				
			||||||
Ben Morgan
 | 
					Ben Morgan
 | 
				
			||||||
 | 
					Emily Morehouse
 | 
				
			||||||
Derek Morr
 | 
					Derek Morr
 | 
				
			||||||
James A Morrison
 | 
					James A Morrison
 | 
				
			||||||
Martin Morrison
 | 
					Martin Morrison
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue