datacamp / courses-introduction-to-python

Introduction to Python by Filip Schouwenaars
https://www.datacamp.com/courses/intro-to-python-for-data-science
415 stars 266 forks source link

learnpython.org: Classes_and_Objects static var represented as instance var #50

Closed dz0 closed 7 years ago

dz0 commented 7 years ago

Hi, not sure if I should address the issue here, but maybe you can redirect :)

in https://www.learnpython.org/en/Classes_and_Objects in Accessing Object Variables in 3-rd exercise

class MyClass:
    variable = "blah"

    def function(self):
        print("This is a message inside the class.")

myobjectx = MyClass()
myobjecty = MyClass()

myobjecty.variable = "yackity"

# Then pring out both values
print(myobjectx.variable)
print(myobjecty.variable)

explanation does'nt mention, that new instance variable is created (and overrides static variable for that instance) And doesn't mention possibility of MyClass.variable = "asdf"

imo, instead should be introduced

    __init__(self):
         self.variable = "blah"
westonstearns commented 7 years ago

@yashasroy support@learnpython.org

yashasroy commented 7 years ago

@dz0 All learnpython.org related issues can be addressed to support@learnpython.org. As this repository pertains to DataCamp's Intro to Python for Data Science course, I'm closing this. If you come across any issues in DataCamp courses, please feel free to report it to us via the 'Report an Issue' button (as shown below), and we'll look into it. Thanks! :)

screenshot 2017-09-27 23 26 11