A collection of notes to go over in class, to keep things organized.
It is a good idea to make a property to access information in your class that requires “inside information”, For example, in a Donor class:
@property
def maxdonation(self):
return max(self.donations)
This way, client code can get the maximum donation without knowing, or caring how the donations are stored in the class.
However, there is no need to create a property to “hide” something that is already part of the public API:
@property
def namelength(self):
return(len(self.name))
There is no point to this – a_donor.name is expected to be a string – so if you want to know how long it is, you can simply do: len(a_donor.name)
You do want to use properties to “hide” implementation details – but the name attribute being a string is part of the API, not an implementation detail.
Next quarter, we’ll finish up the core of the Python language, then go into depth on some of the more advanced features of the language. Finally, we’ll do a bit with using Python with other tools, such as databases.
Here’s a Tentative Outline:
Object/Document, Key/Value and Graph Databases
The readings were a little, shall we say, sparse.
So I’ll go over them now.
We will review PRs through Sunday.
I will hold office hours one last time this Sunday as well.
Anyone up for Celebratory Beer?