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') >>> X & Y # Intersection >>> X | Y # Union >>> X – Y # Difference 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 >>> 1 > 2, 1 < 2 # Booleans >>> X = None # None placeholder >>> type(L) # Types
blog comments powered by Disqus |