August 2018
Intermediate to advanced
466 pages
10h 23m
English
Python is an object-oriented programming (OOP) language. The way Python creates objects is with the class keyword. A Python object is most commonly a collection of functions (methods), variables, and attributes (properties). Once a class is defined, you can create instances of such a class. The class serves as a blueprint for subsequent instances.
The topic of OOP is outside the scope of this chapter, so here is a simple example of a router object definition:
>>> class router(object):... def __init__(self, name, interface_number,vendor):... self.name = name... self.interface_number = interface_number... self.vendor = vendor...>>>
Once defined, you are able to create as many instances of that class as you'd like:
>>> r1 = router("SFO1-R1", ...Read now
Unlock full access