F

factorials, On the other hand: Space and time, conciseness, expressiveness, Test Your Knowledge: Part IV Exercises, Part IV, Functions and Generators
factory functions, Factory Functions: ClosuresClosures versus classes, round 1, Enclosing scopes and loop variables: Factory functions, Classes Are Objects: Generic Object FactoriesWhy Factories?, Using simple factory functions
about, Factory Functions: ClosuresClosures versus classes, round 1
generic, Classes Are Objects: Generic Object FactoriesWhy Factories?
gotchas, Enclosing scopes and loop variables: Factory functions
metaclasses and, Using simple factory functions
false value in Python, Booleans, The Meaning of True and False in PythonThe bool type, Truth Values and Boolean TestsTruth Values and Boolean Tests, Redefining built-in names: For better or worse, Boolean Tests: __bool__ and __len__Boolean Methods in Python 2.X
Booleans and, Booleans, The Meaning of True and False in PythonThe bool type, Truth Values and Boolean TestsTruth Values and Boolean Tests
built-in scope and, Redefining built-in names: For better or worse
operator overloading and, Boolean Tests: __bool__ and __len__Boolean Methods in Python 2.X
FieldStorage class, The has_key method is dead in 3.X: Long live in!
FIFO (first-in-first-out), Recursion versus queues and stacks
__file__ attribute, Example: Modules Are Objects
files (file object), Usage Notes: Command Lines and Files, Python’s Core Data Types, Files, Files, Files, Files, Files, Files, Other File-Like Tools, Files, Files, Files, Files, Files, Files, Files, Files, Files, Files, Opening Files, Using FilesUsing Files, Using Files, Using Files, Files in Action, Files in Action, Files in Action, Files in Action, Files in Action, Files in Action, Storing Python Objects in Files: ConversionsStoring Python Objects in Files: Conversions, Storing Python Objects in Files: Conversions, File Context Managers, Other File Tools, Other File Tools, Test Your Knowledge: Quiz, Print Operations, Nested for loops, Nested for loops, Nested for loops, The Iteration Protocol: File IteratorsThe Iteration Protocol: File Iterators, The Iteration Protocol: File Iterators, The Iteration Protocol: File Iterators, The Iteration Protocol: File Iterators, The Iteration Protocol: File Iterators, Manual Iteration: iter and next, Manual Iteration: iter and next, Using List Comprehensions on Files, Using List Comprehensions on Files, Using List Comprehensions on Files, Polymorphism Revisited, Polymorphism Revisited, Program Design: Minimize Cross-File ChangesProgram Design: Minimize Cross-File Changes, On the other hand: performance, conciseness, expressiveness, Module Filenames, Files Generate Namespaces, Package __init__.py FilesPackage initialization file roles, Files Still Have Precedence over DirectoriesFiles Still Have Precedence over Directories, Closing Files and Server Connections, XML Parsing Tools
(see also binary files; text files)
about, Files, Files
close method, Files, Using Files
closing, Closing Files and Server Connections
common operations, Files, Files in Action
context manager, Using Files
context managers, File Context Managers
flush method, Files, Other File Tools
generating namespaces, Files Generate Namespaces
__init__.py files, Package __init__.py FilesPackage initialization file roles
inspecting, XML Parsing Tools
iteration in, Files in Action, The Iteration Protocol: File IteratorsThe Iteration Protocol: File Iterators, On the other hand: performance, conciseness, expressiveness
list comprehensions and, Using List Comprehensions on Files
literals, Python’s Core Data Types
minimizing cross-file changes, Program Design: Minimize Cross-File ChangesProgram Design: Minimize Cross-File Changes
module filenames, Module Filenames
__next__ method, The Iteration Protocol: File Iterators, The Iteration Protocol: File Iterators, Manual Iteration: iter and next, Manual Iteration: iter and next, Using List Comprehensions on Files
open built-in function and, Files, Other File-Like Tools, Opening Files
precedence over directories, Files Still Have Precedence over DirectoriesFiles Still Have Precedence over Directories
print operations and, Print Operations
quiz questions and answers, Test Your Knowledge: Quiz
read method, Files, Files, Files in Action, Nested for loops
readline method, Files, Files, Files in Action, The Iteration Protocol: File Iterators
readlines method, Files, Nested for loops, The Iteration Protocol: File Iterators, Using List Comprehensions on Files, Polymorphism Revisited
seek method, Files, Files, Polymorphism Revisited
storing objects in files, Storing Python Objects in Files: ConversionsStoring Python Objects in Files: Conversions
tools supporting, Other File Tools
type-specific methods, Files, Files in Action
usage considerations, Usage Notes: Command Lines and Files, Using FilesUsing Files
write method, Files, Storing Python Objects in Files: Conversions
writelines method, Files
xreadlines method, Nested for loops
filesystems, access-by-key, The has_key method is dead in 3.X: Long live in! (see access-by-key databases and filesystems)
filter built-in function, Comprehensions, Other Iteration Contexts, New Iterables in Python 3.X, The map, zip, and filter Iterables, Selecting Items in Iterables: filter, Adding Tests and Nested Loops: filterFormal comprehension syntax, Generator expressions versus filter
generator expressions versus, Generator expressions versus filter
iteration and, Other Iteration Contexts, New Iterables in Python 3.X, The map, zip, and filter Iterables, Selecting Items in Iterables: filter
list comprehensions and, Comprehensions, Adding Tests and Nested Loops: filterFormal comprehension syntax
filtering test results, Filter clauses: if
first-class object model, Indirect Function Calls: “First Class” Objects, Functional Programming Tools
first-in-first-out (FIFO), Recursion versus queues and stacks
float built-in function, String Conversion Tools, Type Objects
floating-point numbers (float type), Numbers, Other Core Types, Numeric Literals, Built-in Numeric Tools, Built-in Numeric Tools, Supporting floating-point numbers
about, Numbers, Other Core Types, Numeric Literals
as_integer_ratio method, Built-in Numeric Tools
is_integer method, Built-in Numeric Tools
try statements and, Supporting floating-point numbers
FloatingPointError exception, Built-in Exception Classes
floor division, Division: Classic, Floor, and TrueWhy does truncation matter?
for statement, Entering multiline statements, Sorting Keys: for LoopsSorting Keys: for Loops, Python’s Statements, Advanced sequence assignment patterns, Application to for loops, for Loops, General Format, ExamplesNested for loops, Nested for loopsNested for loops, Nested for loops, Sequence Scans: while and range Versus for, Parallel Traversals: zip and mapDictionary construction with zip, Test Your Knowledge: Quiz, Iterations and Comprehensions, Iterations: A First Look, The Iteration Protocol: File Iterators, The full iteration protocol, Other Built-in Type Iterables, List Comprehensions: A First Detailed Look, Filter clauses: if, Nested loops: for, Loop Statements Versus Recursion
about, Python’s Statements, for Loops
extended sequence unpacking, Application to for loops
filter clauses, Filter clauses: if
general format, General Format
iteration and, Iterations: A First Look, The Iteration Protocol: File Iterators, The full iteration protocol, Other Built-in Type Iterables
list comprehensions and, Nested for loops, Iterations and Comprehensions, List Comprehensions: A First Detailed Look
nested loops, Nested loops: for
nesting, Nested for loopsNested for loops
parallel traversals, Parallel Traversals: zip and mapDictionary construction with zip
quiz questions and answers, Test Your Knowledge: Quiz
range built-in function and, Advanced sequence assignment patterns
recursion versus, Loop Statements Versus Recursion
sequence scans, Sequence Scans: while and range Versus for
sorting keys, Sorting Keys: for LoopsSorting Keys: for Loops
terminating, Entering multiline statements
usage examples, ExamplesNested for loops
format built-in function, Advanced Formatting Method Syntax, Advanced Formatting Method Examples
__format__ method, Advanced Formatting Method Syntax
formatting strings, Numeric Display Formats (see string formatting)
fractions (fraction object), Other Core Types, Fraction Type, Numeric accuracy in fractions and decimals, Fraction conversions and mixed types, Fraction conversions and mixed types
about, Other Core Types, Fraction Type
conversions and mixed types, Fraction conversions and mixed types
from_float method, Fraction conversions and mixed types
numeric accuracy in, Numeric accuracy in fractions and decimals
fractions module, Fraction basics
freeze tool, Frozen Binaries
from * statement, The from * Statement, The from * Statement, Package initialization file roles, Minimizing from * Damage: _X and __all__, from * Can Obscure the Meaning of Variables
about, The from * Statement
modules and, The from * Statement
namespace pollution and, Minimizing from * Damage: _X and __all__
package imports and, Package initialization file roles
variables and, from * Can Obscure the Meaning of Variables
from statement, The Grander Module Story: Attributes, Using exec to Run Module Files, Python’s Statements, Modules: The Big Picture, The from Statement, import and from Are AssignmentsWhen import is required, import and from Equivalence, Potential Pitfalls of the from StatementWhen import is required, Module Packages, Package Import Basics, from Versus import with Packages, The as Extension for import and from, from Copies Names but Doesn’t Link, reload May Not Impact from Importsreload, from, and Interactive Testing, reload, from, and Interactive Testing, Recursive from Imports May Not Work
about, The Grander Module Story: Attributes, Python’s Statements, Modules: The Big Picture, The from Statement, import and from Are AssignmentsWhen import is required
as extension, The as Extension for import and from
copying names, from Copies Names but Doesn’t Link
exec built-in function and, Using exec to Run Module Files
import statement versus, import and from Equivalence, from Versus import with Packages, Recursive from Imports May Not Work
package imports and, Package Import Basics
potential pitfalls, Potential Pitfalls of the from StatementWhen import is required
relative imports model and, Module Packages
reload built-in function and, reload May Not Impact from Importsreload, from, and Interactive Testing
testing and, reload, from, and Interactive Testing
frozen binaries, Frozen Binaries, Frozen Binary Executables
frozenset built-in function, Immutable constraints and frozen sets, Core Types Review and Summary
function attributes, State with Function Attributes: 3.X and 2.XState with mutables: Obscure ghost of Pythons past?, Function AttributesFunction Attributes, Function attributes
function decorators, OOP and Delegation: “Wrapper” Proxy Objects, Property basics, Decorators and Metaclasses: Part 1Function Decorator Basics, A First Look at User-Defined Function Decorators, What’s a Decorator?, Function Decorators, Implementation, Supporting method decoration, Coding Function DecoratorsTiming with decorator arguments, Tracing CallsTracing Calls, Decorator State Retention OptionsFunction attributes, Class Blunders I: Decorating MethodsUsing descriptors to decorate methods, Timing CallsTiming with decorator arguments, Adding Decorator ArgumentsTiming with decorator arguments, Decorators Versus Manager Functions, Example: Validating Function ArgumentsOther Applications: Type Testing (If You Insist!)
about, OOP and Delegation: “Wrapper” Proxy Objects, Decorators and Metaclasses: Part 1Function Decorator Basics, What’s a Decorator?
adding arguments, Adding Decorator ArgumentsTiming with decorator arguments
coding, Coding Function DecoratorsTiming with decorator arguments
implementing, Implementation
manager functions versus, Decorators Versus Manager Functions
method blunders, Class Blunders I: Decorating MethodsUsing descriptors to decorate methods
method declaration and, Supporting method decoration
properties and, Property basics
state retention options, Decorator State Retention OptionsFunction attributes
timing calls, Timing CallsTiming with decorator arguments
tracing calls, Tracing CallsTracing Calls
usage considerations, Function Decorators
user-defined, A First Look at User-Defined Function Decorators
validating arguments, Example: Validating Function ArgumentsOther Applications: Type Testing (If You Insist!)
functional programming, Factory Functions: ClosuresClosures versus classes, round 1, Functional Programming ToolsCombining Items in Iterables: reduce, List Comprehensions and Functional ToolsOn the other hand: performance, conciseness, expressiveness, Classes Generate Multiple Instance Objects
built-in functions for, Functional Programming ToolsCombining Items in Iterables: reduce
classes, Classes Generate Multiple Instance Objects
closures, Factory Functions: ClosuresClosures versus classes, round 1
list comprehensions, List Comprehensions and Functional ToolsOn the other hand: performance, conciseness, expressiveness
functions, Python’s Core Data Types, Python’s Core Data Types, Mapping Operations, Functions versus expressions: A minor convenience, Expression Statements, Other Iteration Contexts, Multiple Versus Single Pass Iterators, Other Iteration Topics, Function BasicsWhy Use Functions?, Coding Functionsdef Executes at Runtime, Definition, Calls, Polymorphism in Python, A Second Example: Intersecting SequencesLocal Variables, Polymorphism Revisited, Test Your Knowledge: Quiz, Scope Details, Scope Details, Program Design: Minimize Cross-File Changes, Scopes and Nested FunctionsArbitrary scope nesting, Factory Functions: ClosuresClosures versus classes, round 1, The Gritty Details, Arbitrary Arguments ExamplesThe defunct apply built-in (Python 2.X), Arbitrary Arguments ExamplesThe defunct apply built-in (Python 2.X), Applying functions genericallyApplying functions generically, Why keyword-only arguments?, Why keyword-only arguments?, Generalized Set FunctionsGeneralized Set Functions, Function Design ConceptsFunction Design Concepts, Function Design Concepts, Function Design Concepts, Function Design Concepts, Recursive FunctionsMore recursion examples, Coding Alternatives, Indirect Function Calls: “First Class” Objects, Function Introspection, Function Annotations in 3.XFunction Annotations in 3.X, Anonymous Functions: lambdaScopes: lambdas Can Be Nested Too, How (Not) to Obfuscate Your Python CodeHow (Not) to Obfuscate Your Python Code, Scopes: lambdas Can Be Nested Too, Functional Programming ToolsCombining Items in Iterables: reduce, Functional Programming Tools, Mapping Functions over Iterables: mapMapping Functions over Iterables: map, Test Your Knowledge: Quiz, Generator Functions and ExpressionsExtended generator function protocol: send versus next, Generator Functions Versus Generator ExpressionsGenerator Functions Versus Generator Expressions, Coding your own zip(...) and map(None, ...), Function GotchasHiding built-ins by assignment: Shadowing, Enclosing scopes and loop variables: Factory functions, A Recursive ReloaderTesting recursive reloads, Recursive from Imports May Not Work, Classes and Instances, Method Calls, A First Example, Example, Namespace Links: A Tree Climber, Unbound Methods Are Functions in 3.X, Classes Are Objects: Generic Object FactoriesWhy Factories?, Decorators and Metaclasses: Part 1Function Decorator Basics, Functions Can Signal Conditions with raise, Managing Functions and Classes, Usage, Decorators Manage Functions and Classes, Too, Using nested functions to decorate methods, Tracing interfaces with class decorators, Decorators Versus Manager Functions, Decorators Versus Manager Functions, Managing Functions and Classes DirectlyManaging Functions and Classes Directly, Generalizing for Keywords and Defaults, Too, Generalizing for Keywords and Defaults, Too, Function introspection, Matching algorithm, Matching algorithm, Decorator Arguments Versus Function AnnotationsDecorator Arguments Versus Function Annotations, The Downside of “Helper” FunctionsThe Downside of “Helper” Functions, The Downside of “Helper” FunctionsThe Downside of “Helper” Functions, Using simple factory functions
(see also specific functions)
about, Python’s Core Data Types, Function BasicsWhy Use Functions?
accessor, Program Design: Minimize Cross-File Changes, Function Design Concepts
annotations and, Function Annotations in 3.XFunction Annotations in 3.X, Decorator Arguments Versus Function AnnotationsDecorator Arguments Versus Function Annotations
anonymous, Anonymous Functions: lambdaScopes: lambdas Can Be Nested Too
applying generically, Applying functions genericallyApplying functions generically
*arg form, Other Iteration Contexts, Arbitrary Arguments ExamplesThe defunct apply built-in (Python 2.X), Why keyword-only arguments?
**args form, The Gritty Details, Arbitrary Arguments ExamplesThe defunct apply built-in (Python 2.X), Why keyword-only arguments?
calling, Calls
classes and, Classes and Instances, Method Calls, Example
coding, Coding Functionsdef Executes at Runtime, Coding Alternatives, How (Not) to Obfuscate Your Python CodeHow (Not) to Obfuscate Your Python Code
cohesion in, Function Design Concepts
common pitfalls, Function GotchasHiding built-ins by assignment: Shadowing
coupling, Function Design Concepts
decorators and, Managing Functions and Classes, Decorators Manage Functions and Classes, Too, Managing Functions and Classes DirectlyManaging Functions and Classes Directly
defining, Definition
design concepts, Function Design ConceptsFunction Design Concepts
expressions versus, Functions versus expressions: A minor convenience, Expression Statements
factory, Factory Functions: ClosuresClosures versus classes, round 1, Enclosing scopes and loop variables: Factory functions, Classes Are Objects: Generic Object FactoriesWhy Factories?, Using simple factory functions
first-class object model, Indirect Function Calls: “First Class” Objects, Functional Programming Tools
generator, Multiple Versus Single Pass Iterators, Other Iteration Topics, Generator Functions and ExpressionsExtended generator function protocol: send versus next, Generator Functions Versus Generator ExpressionsGenerator Functions Versus Generator Expressions
helper, Decorators Versus Manager Functions, The Downside of “Helper” FunctionsThe Downside of “Helper” Functions
intersecting sequences, A Second Example: Intersecting SequencesLocal Variables, Generalized Set FunctionsGeneralized Set Functions
introspection tools, Function Introspection, Function introspection
**kargs form, Coding your own zip(...) and map(None, ...), Tracing interfaces with class decorators, Generalizing for Keywords and Defaults, Too, Matching algorithm
keyword arguments, Mapping Operations
manager, Decorators Versus Manager Functions, The Downside of “Helper” FunctionsThe Downside of “Helper” Functions
mapping operations, Mapping Functions over Iterables: mapMapping Functions over Iterables: map
metafunctions, Decorators and Metaclasses: Part 1Function Decorator Basics, Usage
methods and, A First Example
nesting, Scopes and Nested FunctionsArbitrary scope nesting, Scopes: lambdas Can Be Nested Too, Using nested functions to decorate methods
*pargs form, Generalizing for Keywords and Defaults, Too, Matching algorithm
polymorphism in, Polymorphism in Python, Polymorphism Revisited
programming tools, Functional Programming ToolsCombining Items in Iterables: reduce
quiz questions and answers, Test Your Knowledge: Quiz, Test Your Knowledge: Quiz
recursive, Scope Details, Recursive FunctionsMore recursion examples, A Recursive ReloaderTesting recursive reloads, Recursive from Imports May Not Work, Namespace Links: A Tree Climber
scope considerations, Scope Details
signaling conditions with, Functions Can Signal Conditions with raise
unbound methods as, Unbound Methods Are Functions in 3.X
functools module, Combining Items in Iterables: reduce
__future__ module, Supporting either Python, Importing from __future__, Enabling Future Language Features: __future__