With Python 2.2, classes and instances come in two …
?With Python 2.2, classes and instances come in two flavors: old and new
?New classes cleaned up the language by
? Unifying classes and types ? Allowing all built-in types to be sub-classed
?For compatibility, default 2.x class is old style; Python 3 only has new classes
?New classes support interesting features ?New classes subclass object
class Student(object):
"""A new class representing a student"""
def __init__(self,n,a): self.full_name = n self.age = a
def get_age(self): return self.age
?One neat feature in new classes is the property function
?It's a better way to manage private attributes, and getter and setter methods
?While still keeping access simple
?We'll also see decorators, an interesting feature
class Box(object): def __repr__(self): return "" % (self.length, self.width, self.area)
class Box1(Box): """A rectangle""" def __init__(self, l=1, w=1): self.length = l self.width = w self.area = l * w
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- module 23 cornell university
- object oriented python
- introduction to python programming introduction
- object oriented programming
- python classes new and old
- with python 2 2 classes and instances come in two
- introduction to object oriented programming in
- mit6 0001f16 python classes and inheritance
- python classes and objects
Related searches
- install numpy in python 2 7
- words with friends 2 cheat with board
- 1 2 2 cell membrane structure and function
- writing and solving equations in two variables
- classes and objects in java
- c classes and objects
- install python 2 in jupyter notebook
- kid and play come out as couple
- free ged classes and test online
- antibiotic classes and uses
- does cbd come in urine
- triangle with 2 angles and 1 side