The Real Python Podcast

Exploring Duck Typing in Python & Dynamics of Monkey Patching


Listen Later

What are the advantages of determining the type of an object by how it behaves? What coding circumstances are not a good fit for duck typing? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder’s Weekly articles and projects.

Christopher covers a recent Real Python tutorial by Leodanis Pozo Ramos titled Duck Typing in Python: Writing Flexible and Decoupled Code. The tutorial explains the concepts of duck typing within object-oriented programming and its use within Python’s built-in tools.

We discuss a recent article on monkey patching in Python. This practice of dynamically modifying a class or module’s behavior at runtime allows for testing, debugging, and experimentation.

We also share several other articles and projects from the Python community, including a news roundup, why names are not the same as objects in Python, using IPython Jupyter magic commands, a discussion about becoming a senior developer, a data exploration challenge, a Python evaluation game, and a terminal UI for regex testing.

This week’s episode is brought to you by Sentry.

Course Spotlight: Pointers and Objects in Python

In this video course, you’ll learn about Python’s object model and see why pointers don’t really exist in Python. You’ll also cover ways to simulate pointers in Python without managing memory.

Topics:

  • 00:00:00 – Introduction
  • 00:02:38 – Listener feedback
  • 00:04:02 – DjangoCon US Call for Proposals
  • 00:04:38 – White House Recommends Use of Python
  • 00:05:41 – JupyterLab 4.1 and Notebook 7.1 Released
  • 00:06:05 – What’s in a Name?
  • 00:11:52 – Duck Typing in Python: Writing Flexible and Decoupled Code
  • 00:15:07 – Sponsor: Sentry
  • 00:16:11 – Using IPython Jupyter Magic Commands
  • 00:22:31 – A Guide to Monkey Patching
  • 00:25:27 – Falsehoods Junior Developers Believe About Becoming Senior
  • 00:33:01 – Video Course Spotlight
  • 00:34:11 – Falsehoods continued
  • 00:43:43 – Where in the data?
  • 00:46:55 – the eval game
  • 00:48:03 – rexi: Terminal UI for Regex Testing
  • 00:49:43 – Thanks and goodbye
  • News:

    • DjangoCon US Call for Proposals
    • White House Recommends Use of Python
    • JupyterLab 4.1 and Notebook 7.1 Released
    • Show Links:

      • What’s in a Name? – An article about names in Python, and why they’re not the same as objects. The article discusses reference counts and namespaces.
      • Duck Typing in Python: Writing Flexible and Decoupled Code – In this tutorial, you’ll learn about duck typing in Python. It’s a typing system based on objects’ behaviors rather than on inheritance. By taking advantage of duck typing, you can create flexible and decoupled sets of Python classes that you can use together or individually.
      • Using IPython Jupyter Magic Commands – “IPython Jupyter Magic commands (e.g. lines in notebook cells starting with % or %%) can decorate a notebook cell, or line, to modify its behavior.” This article shows you how to define them and where they can be useful.
      • Monkeying Around With Python: A Guide to Monkey Patching – Monkey patching is the practice of modifying live code. This article shows you how it’s done and why and when to use the practice.
      • Discussion:

        • Falsehoods Junior Developers Believe About Becoming Senior – This opinion piece by Vadim discusses how newer developers perceive what it means to be a senior developer, and how they’re often wrong.
        • Projects:

          • Where in the data?
          • the eval game
          • rexi: Terminal UI for Regex Testing
          • Additional Links:

            • Pointers in Python: What’s the Point? – Real Python
            • Unlock IPython’s Magical Toolbox for Your Coding Journey – Real Python
            • Episode #88: Discussing Type Hints, Protocols, and Ducks in Python – The Real Python Podcast
            • saul.pw
            • BlueBird Shell
            • Level up your Python skills with our expert-led courses:

              • Python Type Checking
              • Testing Your Code With pytest
              • Pointers and Objects in Python
              • Support the podcast & join our community of Pythonistas

                ...more
                View all episodesView all episodes
                Download on the App Store

                The Real Python PodcastBy Real Python

                • 4.7
                • 4.7
                • 4.7
                • 4.7
                • 4.7

                4.7

                139 ratings


                More shows like The Real Python Podcast

                View all
                Software Engineering Radio by se-radio@computer.org

                Software Engineering Radio

                271 Listeners

                The Changelog: Software Development, Open Source by Changelog Media

                The Changelog: Software Development, Open Source

                289 Listeners

                Software Engineering Daily by Software Engineering Daily

                Software Engineering Daily

                624 Listeners

                Talk Python To Me by Michael Kennedy

                Talk Python To Me

                585 Listeners

                Soft Skills Engineering by Jamison Dance and Dave Smith

                Soft Skills Engineering

                288 Listeners

                Super Data Science: ML & AI Podcast with Jon Krohn by Jon Krohn

                Super Data Science: ML & AI Podcast with Jon Krohn

                302 Listeners

                Python Bytes by Michael Kennedy and Brian Okken

                Python Bytes

                215 Listeners

                Syntax - Tasty Web Development Treats by Wes Bos & Scott Tolinski - Full Stack JavaScript Web Developers

                Syntax - Tasty Web Development Treats

                987 Listeners

                REWORK by 37signals

                REWORK

                210 Listeners

                CoRecursive: Coding Stories by Adam Gordon Bell - Software Developer

                CoRecursive: Coding Stories

                190 Listeners

                DataFramed by DataCamp

                DataFramed

                269 Listeners

                Practical AI by Practical AI LLC

                Practical AI

                210 Listeners

                AWS Podcast by Amazon Web Services

                AWS Podcast

                203 Listeners

                The Stack Overflow Podcast by The Stack Overflow Podcast

                The Stack Overflow Podcast

                64 Listeners

                The Pragmatic Engineer by Gergely Orosz

                The Pragmatic Engineer

                64 Listeners