[Modeling-users] custom object initialisation
Status: Abandoned
Brought to you by:
sbigaret
From: Mario R. <ma...@ru...> - 2003-04-21 11:26:47
|
Is there a particular reason why the __init__ generated for custom objects does not allow pre-setting of attribute values? I mean, do not we frequently want to initialise an object with values, e.g. mo = myObj(att1='one', att2='two', ...) instead of having to initialise and then call a setter for each attribute we want to set: mo = myObj() mo.setAtt1('one') mo.setAtt2('two') I.e. instead of something like the following: class myObj(CustomObject): def __init__(self): "Initializer" # Note: if you modify this method, it is a strong requirement that # every parameter gets a default value, since the framework needs to be # able to instanciate an object with no parameter at all. self._att1 = None self._att2 = None why shouldn't we have: class myObj(CustomObject): def __init__(self,att1=None,att2=None): "Initializer" #... self._att1 = att1 self._att2 = att2 Thanks, mario |