[Numpy-discussion] Re: OT:pretty print of reals (was: Community Poll: numarray default underflow handling == "ignore" ?)
a.schmolck at gmx.net
Mon Nov 24 11:48:06 CST 2003
"Sebastian Haase" <haase at msg.ucsf.edu> writes:
> Hi Alexander,
> Thanks for the code - I will look into it
> I just read a few lines of your MatrixFormatter class seeing the definition
> of __repr__.
> Here is a thought: Is it possible that I overload the __repr__ of float
> (that is: the buildin data type) !?
Nope. You can't screw around with methods of builtins -- and this is a (quite
sensible) conscious design decision.
> When I use pyCrust it automatically "fills in" default arguments like,
> So, this probably does not call the sys.displayhook - so __repr__ itself
> would need to be changed.
Nope, whatever pycrust uses needs to be changed (are you *sure* changing
sys.displayhook has no effect on pycrust (it might not change what it "fills
in", but what about actual output?) because that would seem sort of ...
suboptimal. Even so it shouldn't be too difficult to figure out how you can
customize printing in pycrust (by having a look at the pycrust code and/or
reading the manual or asking on the appropriate mailing-list).
> Do you know if that is possible ? (It would recursively fix all list and
> matrix display problems I had ...)
It wouldn't, it would just get you the float and list (tuple etc.) display you
want (arrays/matrices don't call repr on each individual array arguments to
compute their overall repr).
More information about the Numpy-discussion