subdivision of larger method into smaller parts or to reduce code repetition by defining single method that can be called from within other methods as needed while most object-oriented languages provide mechanism to hide or protect the data attributes from outside accesspython does not insteadthe designer of class in python is supposed to indicate what data attributes and methods are suppose to be protected it' then the responsibility of the user of the class not to violate this protection in this textwe use identifier names that begin with single underscore to flag those attributes and methods that should be protected and trust the user of the class to not attempt direct access to those members the class definition in listing illustrates the use of the single underscore to indicate protected attributes it defines line segmentwhich is specified by point objects that represent the endpoints several operations are also defined for use with line segment listing the line py module implements linesegment class constructed from point objects from point import point class linesegment creates line segment object def __init__selffrompointtopoint )self _pointa frompoint self _pointb topoint gets the starting point of the line segment def endpointaself )return self _pointa gets the ending point of the line segment def endpointbself )return self _pointb gets the length of the line segment def lengthself )return self _pointa distanceself _pointb determines if the line is parallel to the -axis def isverticalself )return self _startpoint getx(=self _endpoint getx(gets the slope of the line def slopeself )if self isvertical(not defined for vertical line return none else run self _pointa getx(self _pointb getx(rise self _pointa gety(self _pointb gety(return rise run