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: 10/23/2020 Revision: 0


Latest Updated LinksValid XHTML 1.0 Transitional Valid CSS!Nu Html Checker Firefox53 Chromena IExplorerna
IMAGE

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 8

Culture

Chinese 1097

English 339

Reference 79

Computer

Hardware 249

Software

Application 213

Digitization 32

Latex 52

Manim 205

KB 1

Numeric 19

Programming

Web 289

Unicode 504

HTML 66

CSS 65

SVG 46

ASP.NET 270

OS 429

DeskTop 7

Python 72

Knowledge

Mathematics

Formulas 8

Algebra 84

Number Theory 206

Trigonometry 31

Geometry 34

Coordinate Geometry 2

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

Matter 1

Electric 27

Biology 1

Geography 1


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