At 11:01 AM 1/28/2010 -0600, s...@pobox.com wrote:
pje> If you look for a local variable in each frame containing a format
pje> string, let's say __trace__, you could apply that format string to
pje> a locals+globals dictionary for the frame, in place of dumping all
pje> the locals by default....
I commented on the blog post before noticing all the replies here. I'll
embellish that suggestion by suggesting that instance attributes can be as
valuable when debugging instance methods. Perhaps __trace_self__ (or
similar) could be fed from self.__dict__ if it exists?
New style formatting allows attributes and item indexes to be used:
http://docs.python.org/library/string.html#formatstrings
e.g. "{self.foo}" would render the foo attribute. So, I don't think
trace_self is strictly necessary. (If one wanted to go hogwild, one
could always just allow __trace__ to be a dictionary mapping locals
to format strings, though it loses much of the attractive simplicity
of setting a trace string.)
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com