10 Fundamentals of objects

This chapter covers

  • Inspecting objects
  • Illustrating an object’s lifecycle
  • Copying an object
  • Resolving a variable: the LEGB rule
  • Understanding an object’s callability

Objects are everywhere in Python, as Python is an object-oriented programming (OOP) language by design. We work with objects constantly in our applications. Thus, it’s important to know the fundamentals of using objects, particularly instance objects of a custom class, as they’re the most prevalent data model in applications. In a function, for example, we expect that users may send different types of data, and we can add this flexibility by handling applicable data types accordingly. As another example, copying an object is necessary when we have a working ...

Get Python How-To now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.