Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Metaprogramming with Python

You're reading from   Metaprogramming with Python A programmer's guide to writing reusable code to build smarter applications

Arrow left icon
Product type Paperback
Published in Sep 2022
Publisher Packt
ISBN-13 9781838554651
Length 402 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Sulekha Aloorravi Sulekha Aloorravi
Author Profile Icon Sulekha Aloorravi
Sulekha Aloorravi
Arrow right icon
View More author details
Toc

Table of Contents (21) Chapters Close

Preface 1. Part 1: Fundamentals – Introduction to Object-Oriented Python and Metaprogramming
2. Chapter 1: The Need for and Applications of Metaprogramming FREE CHAPTER 3. Chapter 2: Refresher of OOP Concepts in Python 4. Part 2: Deep Dive – Building Blocks of Metaprogramming I
5. Chapter 3: Understanding Decorators and their Applications 6. Chapter 4: Working with Metaclasses 7. Chapter 5: Understanding Introspection 8. Chapter 6: Implementing Reflection on Python Objects 9. Chapter 7: Understanding Generics and Typing 10. Chapter 8: Defining Templates for Algorithms 11. Part 3: Deep Dive – Building Blocks of Metaprogramming II
12. Chapter 9: Understanding Code through Abstract Syntax Tree 13. Chapter 10: Understanding Method Resolution Order of Inheritance 14. Chapter 11: Creating Dynamic Objects 15. Chapter 12: Applying GOF Design Patterns – Part 1 16. Chapter 13: Applying GOF Design Patterns – Part 2 17. Chapter 14: Generating Code from AST 18. Chapter 15: Implementing a Case Study 19. Chapter 16: Following Best Practices 20. Other Books You May Enjoy

Summary

In this chapter, we have learned how to examine function objects in Python using the concept of reflection and the corresponding applications of reflection, in which we saw how to implement reflection using built-in functions such as id, callable, hasattr, isinstance, issubclass, and property on various Python objects, and we also learned how to apply them to our core example. From all of these concepts, we learned how to examine Python objects such as classes, methods, and functions. From the examples covered under each topic, we also learned how to apply reflection in practical use cases.

Similar to other chapters covered in this book, this chapter, which covered the concept of reflection, also covered changing the behavior of Python objects externally using metaprogramming.

In the next chapter, we will be looking at the concept of generics with some interesting examples.

lock icon The rest of the chapter is locked
Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Metaprogramming with Python
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Modal Close icon
Modal Close icon