Author: bugman Date: Fri Mar 9 10:14:13 2007 New Revision: 3136 URL: http://svn.gna.org/viewcvs/relax?rev=3136&view=rev Log: Fixed the __repr__() method of the MoleculeContainer class. Modified: 1.3/data/mol_res_spin.py Modified: 1.3/data/mol_res_spin.py URL: http://svn.gna.org/viewcvs/relax/1.3/data/mol_res_spin.py?rev=3136&r1=3135&r2=3136&view=diff ============================================================================== --- 1.3/data/mol_res_spin.py (original) +++ 1.3/data/mol_res_spin.py Fri Mar 9 10:14:13 2007 @@ -59,18 +59,30 @@ def __repr__(self): + """The string representation of the object. + + Rather than using the standard Python conventions (either the string representation of the + value or the "<...desc...>" notation), a rich-formatted description of the object is given. + """ + + # Intro. text = "Class containing all the molecule specific data.\n\n" - # Empty. - if not len(self): - text = text + "The class contains no data.\n" + # Objects. + text = text + "\n" + text = text + "Objects:\n" + for name in dir(self): + # Residue list. + if name == 'res': + text = text + " res: The list of the residues of the molecule is the object\n" - # Not empty. - else: - text = text + "The molecule container has the following keys:\n" - for key in self: - text = text + " " + `key` + "\n" - text = text + "\nThese can be accessed by typing 'relax_data_store.res[key]'.\n" + # Skip certain objects. + if match("^_", name) or name == 'res' or name == 'add_list': + continue + + # Add the object's attribute to the text string. + print name + text = text + " " + name + ": " + `getattr(self, name)` + "\n" return text