Real Python Logo

Episode 31: Python Return Statement Best Practices and Working With the map() Function

The Real Python Podcast

Oct 16, 2020 46m

The Python return statement is such a fundamental part of writing functions. Is it possible you missed some best practices when writing your own return statements? This week on the show, David Amos returns with another batch of PyCoder’s Weekly articles and projects. We also talk functional programming again with an article on the Python map function and processing iterables without a loop.

We cover several other articles and projects from the Python community including, interactive data visualization with Pygal, everything you need to know about namedtuples, PEP 638 syntactic macros, python for kids, the new Nvidia Jetson board, and a reinforcement learning project named football.

Topics:

  • 00:00:00 – Introduction
  • 00:01:33 – Interactive Data Visualization in Python With Pygal
  • 00:06:40 – Python’s map(): Processing Iterables Without a Loop
  • 00:12:51 – Everything You Need to Know About Python’s NamedTuples
  • 00:19:46 – PEP 638: Syntactic Macros
  • 00:26:43 – Video Course Spotlight
  • 00:27:57 – The Python return Statement: Usage and Best Practices
  • 00:34:42 – Python for Kids
  • 00:38:03 – Build a Face Recognition System With the Nvidia Jetson Nano
  • 00:42:32 – football: Reinforcement Learning Environment
  • 00:45:51 – Thanks and goodbye

Show Links:

Interactive Data Visualization in Python With Pygal – Pygal is an overlooked library for creating interactive plots that can be turned into SVGs with an optimal resolution for printing or displaying on webpages. Learn how it works in this introductory tutorial.

Python’s map(): Processing Iterables Without a Loop – In this step-by-step tutorial, you’ll learn how Python’s map() works and how to use it effectively in your programs. You’ll also learn how to use list comprehension and generator expressions to replace map() in a Pythonic and efficient way.

Everything You Need to Know About Python’s NamedTuples – Are you using NamedTuple in your code? If you aren’t, learn what they are and why you should consider using them in this comprehensive tutorial.

PEP 638: Syntactic Macros – This brand new PEP, which is still in draft mode, proposes adding support for syntactic macros to Python. Syntactic macros are compile-time functions that extend the language’s syntax without adding any new complexity to the language as a whole.

The Python return Statement: Usage and Best Practices – In this step-by-step tutorial, you’ll learn how to use the Python return statement when writing functions. Additionally, you’ll cover some good programming practices related to the use of return. With this knowledge, you’ll be able to write readable, robust, and maintainable functions in Python.

Python for Kids – In this ten part series, senior software engineer Kevin Thomas presents a kid-friendly comprehensive Python development tutorial utilizing a micro:bit development board. The GitHub repo contains all of the sample code as well as links to each tutorial in the series on LinkedIn. The first seven parts are published and the last three are coming soon!

Projects:

Build a Face Recognition System With the Nvidia Jetson Nano 2GB and Python – The Nvidia Jetson Nano is a single board computer similar to a Raspberry Pi. The Jetson Nano really packs a punch, however, thanks to its onboard Nvidia Maxwell GPU.

football: Reinforcement Learning Environment Where Agents Learn to Play Football

Additional Links: