Exploring Duck Typing in Python & Dynamics of Monkey Patching
Mar 15, 2024
auto_awesome
Topics discussed include duck typing in Python, benefits and drawbacks, monkey patching for runtime behavior modification, Python community articles, becoming a senior developer, data exploration challenges, Python evaluation game, and regex testing with a terminal UI.
Duck typing in Python simplifies code development by allowing objects to respond to a set of calls.
Monkey patching in Python enables runtime code changes for bug fixes and testing mocks, offering dynamic coding flexibility.
IPython Jupyter magic commands enhance code history navigation and data loading, with potential for creating custom commands.
Deep dives
Duct Typing Explained in Python
Duct typing in Python allows objects to respond to a set of calls, enabling flexibility and simplicity in code development. Classes like duck, swan, and albatross with similar methods demonstrate its practical use.
Monkey Patching in Python
Monkey patching in Python involves making runtime changes to code, enabling bug fixes in third-party libraries and creating mocks for testing. It offers a powerful but potentially complex tool for dynamic coding.
Magic Commands in Python
IPython Jupyter magic commands allow navigating the file system, loading data, and enhancing code history. Custom magic commands can be created for advanced functionality, like automating workflows within notebooks.
Challenges of Senior Developers
Becoming a senior developer involves dispelling myths like having all answers, working with the latest tech, and avoiding routine tasks. The senior role may also entail more managerial duties, meetings, and documentation responsibilities.
Data Puzzle Game 'Damaged Goods'
Explore the data puzzle game 'Damaged Goods' for honing data wrangling skills and exploring tools like Pandas and Jupyter Notebooks. Consider data puzzle games as an engaging way to practice beyond tutorials.
Regular Expression Tool 'Rexy'
Rexy is a text-based UI for regular expression testing developed with Python's textual library. It enables locally testing regex patterns on specific content, offering a split interface for inputting regex, interacting with content, and visualizing grouping results.
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.
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
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.