Hello,<br>I like create a methode that display all the properties of an instance of classe with their value.<br>I try the following code: see def __str__ (self) methode.<br>But it displays only the instance attributes values not the properties and their value.<br>In pseudo-code:<br>For Each Properties :<br> print property_name, property_value<br><br>It is possible ? Where is the collection of properties into the Python Object Metamodele?<br><br>Thank you.<br>Zorgi<br><br>class PhysicalObject(Subject):<br> """<br> Base class for physical Object<br> They inherit from Subject whose contract are:<br> def attach(self, observer)<br> def detach(self, observer)<br> def notify(self, modifier = None)<br> <br>
"""<br> def __init__(self, World, Space, ThePhysicalProperties):<br> """<br><br> """<br> #Initialize Subject-Observers mecanism<br> Subject.__init__(self)<br> self.__name = None<br> ....<br> <br> ...<br> def __str__ (self):<br> """<br> Return a string that describe the value of all attributes for the instance<br> """<br> result = None<br> msgList = ["%s --->%s"%(str(attribute), str(value)) for (attribute, value)
in self.__dict__.items()]<br> msgList.sort()<br> result = "\n\n%s instance :" % (self.__class__.__name__)<br> result += "\n".join (msgList)<br> return result<br> <br> <br> Name = property(fget = __getName, fset = __setName)<br> Position = property(fget = __getPosition, fset = __setPosition)<br> LinearVelocity = property(fget = __getLinearVelocity, fset =
__setLinearVelocity)<br> AngularVelocity = property(fget = __getAngularVelocity, fset = __setAngularVelocity)<br> RotationMatrice = property(fget = __getRotationMatrice, fset = __setRotationMatrice)<br> Masse = property(fget = __getMass, fset = __setMass)<br> GravityMode = property(fget = __getGravityMode, fset = __setGravityMode)<br><br><br><br><p>
<hr size="1">
Ne gardez plus qu'une seule adresse mail ! <a href="http://www.trueswitch.com/yahoo-fr/">Copiez vos mails</a> vers Yahoo! Mail