Skip to Content
Tkinter GUI Application Development Blueprints, Second Edition - Second Edition
book

Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

by Bhaskar Chaudhary
March 2018
Beginner to intermediate
422 pages
10h 33m
English
Packt Publishing
Content preview from Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

Using filter and map

Python provides two built-in functions, named filter and map, to manipulate collections directly rather than having to iterate over each item in the collection. The filter, map, and reduce functions are faster than loops because a lot of the work is done by the underlying code written in C.

The filter(function, list) function returns a list (iterators in Python 3.x) that contains all the items for which the function returns a true value. The following command is an example:

print filter(lambda num: num>6, range(1,10))# prints [7, 8,9]

This is faster than running a conditional if-then check against the list.

The map(function_name, list) function applies function_name to each item in the list and returns the values in a ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Tkinter GUI Application Development Blueprints

Tkinter GUI Application Development Blueprints

Bhaskar Chaudhary

Publisher Resources

ISBN: 9781788837460Supplemental Content