1. Learn
  2. /
  3. Courses
  4. /
  5. Object-Oriented Programming in Python

Connected

Exercise

Read-only properties

The LoggedDF class from Chapter 2 was an extension of the pandas DataFrame class that had an additional created_at attribute that stored the timestamp when the DataFrame was created, so that the user could see how out-of-date the data is.

But that class wasn't very useful: we could just assign any value to created_at after the DataFrame was created, thus defeating the whole point of the attribute! Now, using properties, we can make the attribute read-only.

The LoggedDF class from Chapter 2 is available for you in the script pane.

Instructions 1/3

undefined XP
    1
    2
    3
  • Assign a new value of '2035-07-13' to the created_at attribute.
  • Print the value of ldf's created_at attribute to verify that your assignment was successful.