[PYTHON MATRIX-SIG] [Q] Array->String conversion, how?
MARTIN GEGENHEIMER AK kappes
martin@ipc2ibm1.chemie.uni-karlsruhe.de
Thu, 23 May 1996 13:51:45 +0200 (MSZ)
Forwarded message:
> From root Thu May 23 13:42:41 1996
> Date: Thu, 23 May 96 07:37:58 EDT
> Message-Id: <9605231137.AA02767@acdc.eeel.nist.gov>
> From: Michael McLay <mclay@eeel.nist.gov>
> To: martin@tchibm3.chemie.uni-karlsruhe.de (MARTIN GEGENHEIMER AK kappes)
> Subject: [PYTHON MATRIX-SIG] [Q] Array->String conversion, how?
> In-Reply-To: <9605230818.AA26109@ipc2ibm1.chemie.uni-karlsruhe.de>
> References: <9605230818.AA26109@ipc2ibm1.chemie.uni-karlsruhe.de>
>
> MARTIN GEGENHEIMER AK writes:
> > Hello,
> >
> > I think I need som help:
> >
> > I'd like to convert a numeric array to a string like
> > (to pass it to Tcl)
> >
> > { 1.0 2.0 .... }
> >
> > I tried :
> >
> > str(), repr(), but that gives me :
> > "array([0,1,2,3,4,5,6,7,8,9], 'l')"
> >
> > a.toList() is much more what I want (its also fast for larger arrays)
> >
> > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
> > but I don't want ',' or braces.
> >
> > a.toString()
> > does no do what I want.
> >
> >
> > so, how ?
> >
> > maybe make a modified toList() ?
>
>
> How about using a.toList() to produce
> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>
> and then do a gsub to replace ", " with " ".
>
I wanted to do that when everything else fails. :-(
- Martin
--
Martin Gegenheimer
Institut fuer Physikalische Chemie II
Kaiserstr.12
76128 Karlsruhe
Germany
home-page: http://www.chemie.uni-karlsruhe.de/~martin
e-mail: martin@ipc2ibm1.chemie.uni-karlsruhe.de
voice: ++49 721 608-3255
fax : ++49 721 608-3310
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================