Name

Object

Examples
class HLine(object):  # Class definition
  def __init__(self, ypos, stroke_color):  # Object constructor
    self.ypos = ypos
    self.stroke_color = stroke_color

  def display(self):  # Display method
    stroke(self.stroke_color)
    line(0, self.ypos, width, self.ypos)

# Declare and construct two objects (h1 and h2) of the class HLine(object):
h1 = HLine(20, 0)
h2 = HLine(50, 255)

background(127)
h1.display()
h2.display()
Description Objects are instances of classes. A class is a grouping of related methods (functions) and fields (variables and constants).
Syntax
instanceName = ClassName()
Parameters
ClassNamethe class from which to create the new object
instanceNamethe name for the new object
Related class
Updated on Tue Jul 11 06:52:24 2017.
Creative Commons License