Discord
Login
Community
DARK THEME

How to do anything in python

I mainly wanna know how to create, use classes and draw sprites from objects I made with classes because nowhere online did I find anything about it

For classes: / I'll pretend you know OOP

# Let's say we want a person class:

class person:
  def __init__(self, name, age): # The self name is important
     self.name = name
     self.age = age
  def sayHi(name):
     print("Hi! " + str(name))

# Make a 'person obj'
john = new person("john", 16)

# Get his attributes
print(john.name)
print(john.age)

# Call Functions
john.sayHi("Susan")

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community