@@ -590,7 +590,7 @@ they add the ability to access fields by name instead of position index.
590590 :options: +NORMALIZE_WHITESPACE
591591
592592 >>> # Basic example
593- >>> Point = namedtuple(' Point' , ' x y ' )
593+ >>> Point = namedtuple(' Point' , [ ' x ' , ' y ' ] )
594594 >>> p = Point(x = 10 , y = 11 )
595595
596596 >>> # Example using the verbose option to print the class definition
@@ -735,15 +735,15 @@ functionality with a subclass. Here is how to add a calculated field and
735735a fixed-width print format:
736736
737737 >>> class Point (namedtuple (' Point' , ' x y' )):
738- ... __slots__ = ()
739- ... @ property
740- ... def hypot (self ):
741- ... return (self .x ** 2 + self .y ** 2 ) ** 0.5
742- ... def __str__ (self ):
743- ... return ' Point: x=%6.3f y=%6.3f hypot=%6.3f ' % (self .x, self .y, self .hypot)
738+ __slots__ = ()
739+ @property
740+ def hypot(self):
741+ return (self.x ** 2 + self.y ** 2) ** 0.5
742+ def __str__(self):
743+ return 'Point: x=%6.3f y=%6.3f hypot=%6.3f' % (self.x, self.y, self.hypot)
744744
745745 >>> for p in Point(3 , 4 ), Point(14 , 5 / 7 ):
746- ... print (p)
746+ print(p)
747747 Point: x= 3.000 y= 4.000 hypot= 5.000
748748 Point: x=14.000 y= 0.714 hypot=14.018
749749
@@ -770,7 +770,7 @@ and more efficient to use a simple class declaration:
770770 >>> Status.open, Status.pending, Status.closed
771771 (0, 1, 2)
772772 >>> class Status :
773- ... open , pending, closed = range (3 )
773+ open, pending, closed = range(3)
774774
775775.. seealso ::
776776
0 commit comments