Sideway
output.to from Sideway
Draft for Information Only

Content

Python Built-in Conversion Functions
filter()
  Parameters
  Remarks
iter()
  Parameters
  Remarks
map()
  Parameters
  Remarks
 Source and Reference

Python Built-in Conversion Functions

The Python interpreter has some built-in conversion functions.

filter()

filter(function, iterable)

Parameters

type()to return an iterator from iterable for which function returns true. functionto specify the function to be used for testing iterableto specify an iterable to be returned from

Remarks

  • filter constructs an iterator from those elements of iterable for which function returns true
  • iterable may be either a sequence, a container which supports iteration, or an iterator.
  • If function is None, the identity function is assumed, that is, all elements of iterable that are false are removed.
  • If function is not None, filter(function, iterable) is equivalent to the generator expression (item for item in iterable if function(item)), filter(function, iterable) is equivalent to
  • if function is None, (item for item in iterable if item)
  • See itertools.filterfalse() for the complementary function that returns elements of iterable for which function returns false.

iter()

iter(object[, sentinel])

Parameters

iter()to return an iterator object. objectto specify an object to be returned from [sentinel]to specify sentinel

Remarks

  • If sentinel is omitted, object must be a collection object which supports the iteration protocol (the __iter__() method), or it must support the sequence protocol (the __getitem__() method with integer arguments starting at 0). If it does not support either of those protocols, TypeError is raised.
  • If sentinel is specified, then object must be a callable object. The iterator created in this case will call object with no arguments for each call to its __next__() netgid; if the value returned is equal to sentinel, StopIteration will be raised, otherwise the value will be returned.
  • One useful application of the second form of iter() is to build a block-reader.

map()

map(function, iterable, ...)

Parameters

map()to return an iterator that applies function to every item of iterable, yielding the results. functionto specify the function to be used for applying iterableto specify the iterable to be applied to

Remarks

  • If additional iterable are passed, function must take that many arguments and is applied to the items from all iterables in parallel.
  • With multiple iterables, the iterator stops when the shortest iterable is exhausted.
  • For cases where the function inputs are already arranged into argument tuples, as in itertools.starmap()

Source and Reference


©sideway

ID: 201002302 Last Updated: 23/10/2020 Revision: 0

IMAGE

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 8

Culture

Chinese 1097

English 337

Reference 67

Computer

Hardware 151

Software

Application 202

Digitization 25

Latex 10

Manim 159

Numeric 19

Programming

Web 285

Unicode 494

HTML 65

CSS 59

ASP.NET 194

OS 391

DeskTop 7

Python 37

Knowledge

Mathematics

Formulas 8

Algebra 29

Number Theory 206

Trigonometry 18

Geometry 18

Calculus 67

Complex Analysis 21

Engineering

Tables 8

Mechanical

Mechanics 1

Rigid Bodies

Statics 92

Dynamics 37

Fluid 5

Fluid Kinematics 5

Control

Process Control 1

Acoustics 19

FiniteElement 2

Natural Sciences

Electric 27

Biology 1

Geography 1


Copyright © 2000-2021 Sideway . All rights reserved Disclaimers last modified on 06 September 2019