Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

735
Views
Difference between instance attributes and class attributes?
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The fundamental difference is that class attributes are shared by all instances of that class, while instance attributes are unique to each object created with that class. Thus, instance variables are for data unique to each object and class variables are for attributes that must be shared by all instances of that class.

  • Instance attributes are created using the syntax instance.attr or self.attr ( self is really a convention, it's just an identifier that refers to the instance itself). As has been said, they are local to that instance and therefore only accessible from one of them.

  • Class attributes are defined outside of any class methods, usually just below the documentation string. They can be referenced directly from the class and can also be referenced from any instance of the class. Common uses are to create an enumerated constant, as a control variable in a Singleton, to set default values for instance variables, to define constants, etc.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!