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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -