5 Respuestas
+ 4
If I understand your question correctly
I belive this is the answer?
"All methods must have self as their first parameter, although it isn't explicitly passed, Python adds the self argument to the list for you; you do not need to include it when you call the methods. Within a method definition, self refers to the instance calling the method.
Instances of a class have attributes, which are pieces of data associated with them.
In this example, Cat instances have attributes color and legs. These can be accessed by putting a dot, and the attribute name after an instance.
In an __init__ method, self.attribute can therefore be used to set the initial value of an instance's attributes."
class Cat:
def __init__(self, color, legs):
self.color = color
self.legs = legs
felix = Cat("ginger", 4)
print(felix.color)
+ 1
Interesting, but not quite. I meant to refer to cases in which a function is after the period, such as txt.sort(). In such cases, it's unclear if the part before the period is an argument as though sort(txt) or a class such as List.sort().
+ 1
guiltFear7
Maybe you mean class method vs instance method?
https://pynative.com/JUMP_LINK__&&__python__&&__JUMP_LINK-class-method-vs-static-method-vs-instance-method/
+ 1
I haven't gotten there in the lessons, so I don't know what the difference is between the types of methods.
+ 1
Take your time to understand the basic concepts.
They all stack upon each other and you should build a solid foundation first.
Curiosity is a good sign, because that means you are learning actively.🤓