Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

736
Visualizações
Difference between instance attributes and class attributes?
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda