instance variables and class variables

Total Post:113

Points:791
Python 
 1103  View(s)
Ratings:
Rate this:

How are instance variables different from class variables in python ?

  1. Post:140

    Points:984
    Re: instance variables and class variables

    instance variables different from class variables :

    Instance variables are variables that are created locally within a class to refer to an object of  the class. class variable is which is created globally in a class and its accessible within all  instance of that current class. 

    class variables are declared with keyword static and Instance variables are declared without static keyword. 

    Class variables can be accessed anywhere within that class while an instance variable can only be  accessed within the particular object of the class. 

    As class variables are common to all objects of a class, changes made to these variables through one object will reflect in another. instance variables are own copied of each objects.we cant change in any object. 

    Class variables can be accessed using class name/object reference. Instance variables can be accessed only through the object reference.

Answer

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.