Jump to content

Phython Tutorial


Svetlana

Recommended Posts

There's no enough explanation to the variables used in the tutorials.  For example, what is "self"?  Is it an object or just a parameter?

class Person:
  def __init__(self, name, age):
    self.name = name
    self.age = age

p1 = Person("John", 36)

print(p1.name)
print(p1.age)

Link to comment
Share on other sites

It is explained on this page: https://www.w3schools.com/python/python_classes.asp

Quote

Note: The self parameter is a reference to the current instance of the class, and is used to access variables that belong to the class.

Following the note is an entire section talking about the self parameter.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...