What is the difference between attributes and local variables? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the difference between attributes and local variables?

25th Apr 2017, 10:51 PM
Tina
2 Answers
+ 4
a local variable has scope only in the block of code in that is defined. in the other Hand, an attibute is bind to a specific object, and can define the object's behavior. The object can interact in many modules, thank to the encapsutation property
25th Apr 2017, 11:02 PM
⏩▶Clau◀⏪
⏩▶Clau◀⏪ - avatar
+ 1
Attributes are local variables belonging to an object.
25th Apr 2017, 10:54 PM
Bebida Roja
Bebida Roja - avatar