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 Mon Sep 21 15:53:25 2020.

If you see any errors or have comments, please let us know.