Hi everyone! 2011/1/11 Matti Airas <[email protected]>: > Farsmo filed a bug about the __repr__ representation of PySide objects [1], > requesting us to drop the address information and slightly modify the syntax > for some classes. Since some discussion on the bug itself ensued, I thought > it might be a good idea to give a heads-up on the mailing list so that > people can voice their opinions. So, please do. :-)
I'm voting for the "valid Python expression" output of "__repr__". Previously when I had to debug something (incidentally also with QPoint), I ended up doing something like this for a list of QPoint objects: print [(p.x(), p.y()) for p in points] This way, I get an even nicer output (for debugging), but of course I have to write that myself instead of just saying "print points". What about objects that cannot be instantiated by themselves, and are rather created by some factory method of another class? Should the __repr__ for such objects just be an informative representation that isn't an executable Python expression? When (for a list of QPoint objects) I can just "print points" and then copy that output into another interactive shell (even after my program has finished executing), I can play around with that list (check distances, etc.. - whatever my use case is) without having to resort to print statements or pdb. For other objects like QMainWindow, the constructor signature might not be that useful, but rather things like the position, size, visibility, etc.. - but is this going to be too complicated then? It would really help in debugging without having to write separate "give me some state information about this object in nicely printed form" functions. HTH. Thomas _______________________________________________ PySide mailing list [email protected] http://lists.openbossa.org/listinfo/pyside
