python - Variable assignment in the constructor -
i have question variable assignment in constructor: have constructer takes argument 'context'. first, assign variable class variable. second, create class takes 'context' argument.
to question: better assignment class variable (self.context) or argument constructor (context) new created class?
class state(): def __init__(self, context): self.context = context self.diconnected = disconnected(self.context)
or
class state(): def __init__(self, context): self.context = context self.diconnected = disconnected(context)
the end result same. disconnected(context)
shorter , faster.
Comments
Post a Comment