+ 1

What is the difference between an attribute and a property?

11th Oct 2016, 8:46 PM
Bart Genuit
Bart Genuit - avatar
5 odpowiedzi
+ 2
From courses: "parameter is a named enntity in a function(or method) definition that specifies an argument that the function can accept" "Instance of a class have attributes, which are pieces of data associated with them" and example: class Dog: def __init__(self, name, color): self.name = name self.color = color def bark(self): print("Woof!") fido = Dog("Fido", "brown") print(fido.name) fido.bark() in this example you created object fido (it's parameter for class Dog, and if you want call method of this class you use "fido" - for example fido.bark) class Dog with two attributes - name and color. Another word, "self." it's parameter "name", "color" it's attribute.
11th Oct 2016, 9:09 PM
Kaziu (Mark K.)
Kaziu (Mark K.) - avatar
+ 1
It seems properties are a special kind of attribute
11th Oct 2016, 8:50 PM
Bart Genuit
Bart Genuit - avatar
+ 1
@Marek, thanks, but I didn't ask about parameters, I asked about properties, which I don't think are the same thing.
11th Oct 2016, 9:13 PM
Bart Genuit
Bart Genuit - avatar
+ 1
I think that attribute is the same property. attribute or property are instamce of a class example class car { var color:string // attribute or property color var type:int // attribute or property type }
11th Oct 2016, 9:38 PM
NDUNGUTSE Mukosa
NDUNGUTSE Mukosa - avatar
+ 1
attributes can be changed but property is not change.
4th Jan 2017, 3:17 AM
Ravi Verma
Ravi Verma - avatar