The Real Python Podcast

Getting Started With Refactoring Your Python Code


Listen Later

Do you think it’s time to refactor your Python code? What should you think about before starting this task? This week on the show, we have Brendan Maginnis and Nick Thapen from Sourcery. Sourcery is an automated refactoring tool that integrates into your IDE and suggests improvements to your code.

Nick and Brendan provide advice on how to start refactoring and setting achievable code objectives. We discuss setting up unit testing and building confidence that you aren’t changing your code’s fundamental meaning. We also talk about technical debt and how it can creep into your organization’s projects.

Course Spotlight: Python Booleans: Leveraging the Values of Truth

In this course, you’ll learn about the built-in Python Boolean data type, which is used to represent the truth value of an expression. You’ll see how to use Booleans to compare values, check for identity and membership, and control the flow of your programs with conditionals.

Topics:

  • 00:00:00 – Introduction
  • 00:01:31 – What is refactoring?
  • 00:03:19 – How is it connected to extensibility?
  • 00:04:33 – What are methods for preparing your code?
  • 00:05:35 – Being confident you are not changing the meaning of the code
  • 00:09:34 – Refactoring as you go
  • 00:11:16 – What is technical debt, how is it generated?
  • 00:19:08 – Sponsor: Digital Ocean
  • 00:19:45 – Code metrics
  • 00:23:32 – Holding code in your head, and design patterns
  • 00:28:03 – Comments in code and function definitions
  • 00:35:04 – Automated refactoring
  • 00:39:34 – Using a code formatter
  • 00:43:19 – Video Course Spotlight
  • 00:44:27 – Team decisions around refactoring
  • 00:47:41 – Examples where refactoring made a difference
  • 00:51:56 – A few additional notes about Sourcery
  • 00:52:59 – What is something you are excited about in the world of Python?
  • 00:55:21 – What do you want to learn next?
  • 00:56:20 – Thanks and goodbye
  • Show Links:

    • Sourcery.ai - Write Better Code Faster
    • Episode 49: The Challenges of Developing Into a Python Professional
    • Black - The uncompromising code formatter
    • Effective Python Testing With Pytest - Real Python Article
    • PEP 636 – Structural Pattern Matching: Tutorial
    • Announcing Pylance: Fast, feature-rich language support for Python in Visual Studio Code
    • Episode 28: Using Pylance to Write Better Python Inside of Visual Studio Code
    • The Scala Programming Language
    • PEP 572 – Assignment Expressions
    • Assignment Expressions: The Walrus Operator - Real Python Video Lesson
    • Starlette: The little ASGI framework that shines
    • FastAPI framework, high performance, easy to learn, fast to code, ready for production
    • Refactoring: Prepare Your Code to Get Help - Real Python Code Conversation
    • Level up your Python skills with our expert-led courses:

      • Python Booleans: Leveraging the Values of Truth
      • Test-Driven Development With pytest
      • Debugging in Python With pdb
      • 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

        136 ratings


        More shows like The Real Python Podcast

        View all
        Software Engineering Radio - the podcast for professional software developers by se-radio@computer.org

        Software Engineering Radio - the podcast for professional software developers

        272 Listeners

        The Changelog: Software Development, Open Source by Changelog Media

        The Changelog: Software Development, Open Source

        283 Listeners

        Thoughtworks Technology Podcast by Thoughtworks

        Thoughtworks Technology Podcast

        41 Listeners

        Talk Python To Me by Michael Kennedy

        Talk Python To Me

        592 Listeners

        Software Engineering Daily by Software Engineering Daily

        Software Engineering Daily

        624 Listeners

        Soft Skills Engineering by Jamison Dance and Dave Smith

        Soft Skills Engineering

        269 Listeners

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

        Super Data Science: ML & AI Podcast with Jon Krohn

        298 Listeners

        Python Bytes by Michael Kennedy and Brian Okken

        Python Bytes

        213 Listeners

        Data Engineering Podcast by Tobias Macey

        Data Engineering Podcast

        142 Listeners

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

        Syntax - Tasty Web Development Treats

        982 Listeners

        DataFramed by DataCamp

        DataFramed

        266 Listeners

        Kubernetes Podcast from Google by Abdel Sghiouar, Kaslin Fields

        Kubernetes Podcast from Google

        181 Listeners

        Practical AI by Practical AI LLC

        Practical AI

        190 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

        52 Listeners