[Numpy-discussion] Printing formatted numerical values
Mon Nov 15 09:20:43 CST 2010
On Mon, Nov 15, 2010 at 08:32, <firstname.lastname@example.org> wrote:
> Hi, what is the best way to print (to a file or to stdout) formatted
> numerical values? Analogously to C's printf("%d %g",x,y) etc?
> Numpy Documentation only discusses input *from* a file, or output of
> entire arrays. (np.savetxt()) I just want tab or space-delimited output of
> selected formatted values.
> In the absence of numpy documentation on this matter, I tried to follow
> python documentation and find errors. Below is ipython
> -pylab transcript, which apparently complains that an int32 variable is
> an object of type 'str'. How should I understand this? Does python not
> understand that numpy.int32 is an integer?
Correct. On a 64-bit system, numpy.int32 does not subtype from int.
The format codes do strict type-checking.
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the NumPy-Discussion