Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialanupama shah
341 PointsConfusion on class variable
class Agile: agile = True
def __init__(self, agile=True, *args, **kwargs):
super().__init__(*args, **kwargs)
self.agile = agile
Since we have already agile = True as class variable why is it necessary to set agile = True inisde init() ?
1 Answer
Steven Parker
231,261 PointsA class variable is shared by all instances. But "self.Agile" is an instance variable, and each instance has it's own.
Since this is implemented as an instance variable, the class variable is likely no longer needed.