0% found this document useful (0 votes)
30 views2 pages

Built in

Python's Built-in Types are numerics, sequences, mappings, files, classes, instances. Practically all objects can be compared, tested for truth value, and converted to a string. The following values are considered false: types None -- str, unicode, list,tuple, byte.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views2 pages

Built in

Python's Built-in Types are numerics, sequences, mappings, files, classes, instances. Practically all objects can be compared, tested for truth value, and converted to a string. The following values are considered false: types None -- str, unicode, list,tuple, byte.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Table Of Contents

5. Built-in Types

5. Built-in Types
The following sections describe the standard types that are built into the interpreter.

5.1. Truth Value Note Testing 5.2. Boolean Operations and, or,not 5.3. Comparisons Historically (until release 2.2), Pythons built-in types have differed from user-defined types because it was not possible to use the built-in types as the basis for object-oriented 5.4. Numeric Types inheritance. This limitation no longer exists. int, float, lon g,complex The principal built-in types are numerics, sequences, mappings, files, classes, instances 5.4.1. Bitwise and exceptions. Operations on Integer Types Some operations are supported by several object types; in particular, practically all objects can 5.4.2. Additional be compared, tested for truth value, and converted to a string (with Methods on the repr() function or the slightly different str() function). The latter function is Integer Types implicitly used when an object is written by the print() function. 5.4.3. Additional Methods on Float 5.1. Truth Value Testing 5.5. Iterator Types Any 5.5.1. Generator object can be tested for truth value, for use in an if or while condition or as operand of the Boolean operations below. The following values are considered false: Types 5.6. Sequence Types None str, unicode, list,tuple, byte False array,buffer, xr zero of any numeric type, for example, 0, 0L, 0.0, 0j. ange any empty sequence, for example, '', (), []. 5.6.1. String Methods any empty mapping, for example, {}. 5.6.2. String instances of user-defined classes, if the class defines Formatting a __nonzero__() or __len__() method, when that method returns the Operations integer zero or bool value False. [1] 5.6.3. XRange Type All other values are considered true so objects of many types are always true. 5.6.4. Mutable Operations and built-in functions that have a Boolean result always return 0 or False for Sequence Types false and 1 or True for true, unless otherwise stated. (Important exception: the Boolean 5.7. Set Types operations or and and always return one of their operands.) set,frozenset 5.8. Mapping Types dict 5.2. Boolean Operations and, or, not 5.8.1. Dictionary view objects These are the Boolean operations, ordered by ascending priority: 5.9. File Objects Operation Result Notes 5.10. memoryview x or y if x is (1) type false, 5.11. Context then y, Manager Types else x 5.12. Other Built-in Types x and y if x is (2) 5.12.1. Modules false, then x, 5.12.2. Classes else y and Class Instances not x if x is (3) 5.12.3. Functions false, 5.12.4. Methods then Tr 5.12.5. Code ue, Objects else Fal


index Go

modules | next | previous | Python dev (3.4)3.33.22.7.32.6 Documentation The Python Standard Library
Copyright 1990-2013, Python Software Foundation. The Python Software Foundation is a non-profit corporation. Please donate. Last updated on Jan 02, 2013. Found a bug? Created using Sphinx 1.0.7.

You might also like