Classes in python
Published by Joe Lovick on March 3rd, 2018
lets begin with a simple class
ok so we have some instance level variables type, and age.... what about if we want to give each tree an id, which is unique.
notice the addition of the class level variable, which we refer to with the class name...
ok so what happens when its not a simple variable, instead we need to call a function, this is a function at the class level
you use this when the method has some relation to the class as a whole, rather than the instance, the function has no knowledge of the class though, so we cant get at instance attributes [like treetype etc].... if you need this, then use the @classmethod decorator.
here we use the class method, this allows us to access attributes of the class, which could be quite useful.
Ok lets create and inherited class