Skip to Main Content
Python for Secret Agents
book

Python for Secret Agents

by Steven F. Lott
August 2014
Beginner to intermediate content levelBeginner to intermediate
216 pages
5h 13m
English
Packt Publishing
Content preview from Python for Secret Agents

Creating our own classes of objects

The two lists of data values that HQ asked us to get—cheese consumption and W75 deaths—form two objects that are very similar. They seem to be two instances of the same class of things.

In this case, the class of things seems to have annual statistics. They're collections with a consistent structure of a year and a measurement. Both these annual statistics objects have a common set of operations. Indeed, the operations are pretty tightly bound to the measurement, and they are not at all bound to the year number.

Our collection of statistical functions is not very tightly bound to our data at all.

We can improve the binding between data structure and processing through a class definition. If we define the general ...

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.
Start your free trial

You might also like

Python for Secret Agents - Volume II - Second Edition

Python for Secret Agents - Volume II - Second Edition

Steven F. Lott

Publisher Resources

ISBN: 9781783980420Supplemental Content