Intro to Python for Computer Science and Data Science: Learning to Program with AI, Big Data and The Cloud
by Paul J. Deitel, Harvey M. Deitel
10.17 Wrap-Up
In this chapter, we discussed the details of crafting valuable classes. You saw how to define a class, create objects of the class, access an object’s attributes and call its methods. You define the special method __init__ to create and initialize a new object’s data attributes.
We discussed controlling access to attributes and using properties. We showed that all object attributes may be accessed directly by a client. We discussed identifiers with single leading underscores (_), which indicate attributes that are not meant to be accessed by client code. We showed how to implement “private” attributes via the double-leading-underscore (__) naming convention, which tells Python to mangle an attribute’s name.
We implemented a card ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access