Am I understanding 'self'?


Why Use Classes

Would it be correct to say "self" is just an alternative for the class name. e.g. is the same as

class Fruit(object):
    """A class that makes various tasty fruits."""
    def __init__(self, name, color, flavor, poisonous): = name
        self.color = color
        self.flavor = flavor
        self.poisonous = poisonous


You're close.

It isn't the Class name, but the object name.

So it would be Pear instead of Fruit.


Thank you cadecodes :grin:


You're welcome!

Post again if you get confused. :slight_smile: