class PointWithoutSlots: def __init__( self, xValue = 0.0, yValue = 0.0 ): self.x = float( xValue ) self.y = float( yValue )class PointWithSlots( object ): __slots__ = [ "x", "y" ] def __init__( self, xValue = 0.0, yValue = 0.0 ): self.x = float( xValue ) self.y = float( yValue )noSlots = PointWithoutSlots()slots = PointWithSlots()for point in [ noSlots, slots ]: print "nProcessing an object of class", point.__class__ print "point.x is:", point.x newValue = float( raw_input( "Enter new x coordinate: " ) ) print "set new x-coordinate value..." point.X = newValue print "The new value of point.x is:", point.x
Name (required)
email (will not be published) (required)
Website