Key Differences between Function>Methods>Attributes
1.
Context of Use:
o Function: General-purpose and can be used anywhere in the code.
o Method: Associated with an object; defined within a class and operates on the object’s data.
o Attribute: A piece of data or property associated with an object.
2. How They Are Called:
o Function: Called by its name and can be independent of any object.
o Method: Called on an instance of a class (object), e.g., object.method().
o Attribute: Accessed through an instance of a class, e.g., object.attribute.
3. Scope:
o Function: Can be global or nested within other functions.
o Method: Scoped to the class it is defined in.
o Attribute: Scoped to the instance of the class.
4. Access to Data:
o Function: Does not inherently have access to object data unless passed explicitly.
o Method: Has access to the object’s attributes and other methods.
o Attribute: Holds data that belongs to an object
Please find attached file for details