(self, format_spec)
return cls.__format__(val, format_spec)
Returns format using actual value type unless __str__ has been overridden.
Returns format using actual value type unless __str__ has been overridden.
Returns format using actual value type unless __str__ has been overridden .
def __format__(self, format_spec):
        """
        Returns format using actual value type unless __str__ has been overridden.
        """
        # mixed-in Enums should use the mixed-in type's __format__, otherwise
        # we can get strange results with the Enum name showing up instead of
        # the value

        # pure Enum branch, or branch with __str__ explicitly overridden
        str_overridden = type(self).__str__ not in (Enum.__str__, Flag.__str__)
        if self._member_type_ is object or str_overridden:
            cls = str
            val = str(self)
        # mix-in branch
        else:
            cls = self._member_type_
            val = self._value_
        return cls.__format__(val, format_spec)
def __format__ ( self , format_spec ) : # mixed-in Enums should use the mixed-in type's __format__, otherwise # we can get strange results with the Enum name showing up instead of # the value # pure Enum branch, or branch with __str__ explicitly overridden str_overridden = type ( self ) . __str__ not in ( Enum . __str__ , Flag . __str__ ) if self . _member_type_ is object or str_overridden : cls = str val = str ( self ) # mix-in branch else : cls = self . _member_type_ val = self . _value_ return cls . __format__ ( val , format_spec )