mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 03:44:55 +00:00 
			
		
		
		
	#1228: new comparison behavior.
This commit is contained in:
		
							parent
							
								
									9f27df56f8
								
							
						
					
					
						commit
						9f2c39a775
					
				
					 1 changed files with 5 additions and 12 deletions
				
			
		| 
						 | 
					@ -560,15 +560,8 @@ sequences of the same type::
 | 
				
			||||||
   (1, 2, 3)             == (1.0, 2.0, 3.0)
 | 
					   (1, 2, 3)             == (1.0, 2.0, 3.0)
 | 
				
			||||||
   (1, 2, ('aa', 'ab'))   < (1, 2, ('abc', 'a'), 4)
 | 
					   (1, 2, ('aa', 'ab'))   < (1, 2, ('abc', 'a'), 4)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Note that comparing objects of different types is legal.  The outcome is
 | 
					Note that comparing objects of different types with ``<`` or ``>`` is legal
 | 
				
			||||||
deterministic but arbitrary: the types are ordered by their name. Thus, a list
 | 
					provided that the objects have appropriate comparison methods.  For example,
 | 
				
			||||||
is always smaller than a string, a string is always smaller than a tuple, etc.
 | 
					mixed numeric types are compared according to their numeric value, so 0 equals
 | 
				
			||||||
[#]_ Mixed numeric types are compared according to their numeric value, so 0
 | 
					0.0, etc.  Otherwise, rather than providing an arbitrary ordering, the
 | 
				
			||||||
equals 0.0, etc.
 | 
					interpreter will raise a :exc:`TypeError` exception.
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
.. rubric:: Footnotes
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
.. [#] The rules for comparing objects of different types should not be relied upon;
 | 
					 | 
				
			||||||
   they may change in a future version of the language.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue