Beyond the core types we’ve seen so far, there are others that may or may not qualify for membership, depending on how broad the category is defined to be. Sets, for example, are a recent addition to the language. Sets are containers of other objects created by calling the built-in set function, and they support the usual mathematical set operations:

>>> X = set('spam') >>> Y = set(['h', 'a', 'm']) # Make 2 sets out of sequences >>> X, Y (set(['a', 'p', 's', 'm']), set(['a', 'h', 'm']))

>>> X & Y# Intersection set(['a', 'm'])

>>> X | Y# Union set(['a', 'p', 's', 'h', 'm'])

>>> X – Y# Difference set(['p', 's'])

In addition, Python recently added decimal numbers (fixed-precision floating-point numbers) and Booleans (with predefinedTrueandFalseobjects that are essentially just the integers 1 and 0 with custom display logic), and it has long supported a special placeholder object calledNone:

>>> import decimal # Decimals >>> d = decimal.Decimal('3.141') >>> d + 1 Decimal("4.141")

>>> X = None # None placeholder >>> print X None >>> L = [None] * 100 # Initialize a list of 100 Nones >>> L [None, None, None, None, None, None, None, None, None, None, None, None, None, ...a list of 100 Nones...]

>>> type(L) # Types <type 'list'> >>> type(type(L)) # Even types are objects <type 'type'>