Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6971899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:53:55+00:00 2026-05-27T16:53:55+00:00

To quote diveintopython, You already know about data attributes, which are variables owned by

  • 0

To quote diveintopython,

“You already know about data attributes, which are variables owned by
a specific instance of a class. Python also supports class attributes,
which are variables owned by the class itself.”

In what sense are class attributes owned by a class? If you change the value of a class attribute in a specific instance, that change is only reflected in that instance (and not in other instances of the class).

From my vantage point this makes class attributes fundamentally the same as data (i.e. instance) attributes (notwithstanding the syntactic differences).

In C++ change the value of a “class variable”, and that change is reflected in all instances.

What is the difference between the two?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:53:56+00:00Added an answer on May 27, 2026 at 4:53 pm

    I think that this example will explain the meaning to you.

    class A(object):
        bar = 1
    
    a = A()
    b = A()
    b.bar = 2
    print a.bar  # outputs 1
    A.bar = 3
    print a.bar  # outputs 3
    print b.bar  # outputs 2
    

    In this case b.bar will be owned by instance after b.bar = 2 but a.bar will still be owned by class. That is why it will be changed on instance after changing it on class and b.bar will not.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A quote from MSDN Assigning an instance of this type is not thread safe
A quote from Python Programming: An Introduction to Computer Science We could have taken
To quote PHP: Anonymous functions are currently implemented using the Closure class. This is
We currently have a quote page which lists all existing quotes that we would
Python's urllib.quote and urllib.unquote do not handle Unicode correctly in Python 2.6.5. This is
The following quote is from this link: http://doc.qt.io/qt-5/qwidget.html#setLayout If there already is a layout
To quote the man page: When using condition variables there is always a Boolean
I read the quote data structure(s) is half the code a long time ago,
I have data set as below: Quote: HBOND SUMMARY output to file HB_lowLyo_D_lipid_A_water_001_064.tbl, data
I am writing a quote-matching program in which two Abstract Factory Patterns are required,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.