Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > NumPy chararray and whitespace

Reply
Thread Tools

NumPy chararray and whitespace

 
 
OKB (not okblacke)
Guest
Posts: n/a
 
      06-18-2008
Hi. I'm trying to use NumPy's chararray class for an array of
characters. I notice that when I try to set a chararray element to a
space, it actually gets set to an empty string. I found some pages
online indicating that the chararray strips trailing whitespace from its
values.

I am really, really, hoping this is not a hard-coded, unalterable
behavior. Is there a way to get NumPy chararray to include the
characters I tell it to, without modificiation?

Thanks,
--
--OKB (not okblacke)
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is
no path, and leave a trail."
--author unknown
 
Reply With Quote
 
 
 
 
Robert Kern
Guest
Posts: n/a
 
      06-18-2008
OKB (not okblacke) wrote:
> Hi. I'm trying to use NumPy's chararray class for an array of
> characters. I notice that when I try to set a chararray element to a
> space, it actually gets set to an empty string. I found some pages
> online indicating that the chararray strips trailing whitespace from its
> values.


You should ask numpy questions on the numpy mailing list.

http://www.scipy.org/Mailing_Lists

> I am really, really, hoping this is not a hard-coded, unalterable
> behavior. Is there a way to get NumPy chararray to include the
> characters I tell it to, without modificiation?


Sure. Just subclass chararray and redefine __getitem__ to do what you want.

--
Robert Kern

"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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A More Concise Description of Numpy than the Guide to Numpy? W. eWatson Python 2 11-23-2009 08:58 PM
convert CharArray to ByteArray hierholzer Java 24 06-16-2009 06:36 AM
NumPy Question - numpy.put in multi-dimensional array Bryan.Fodness@gmail.com Python 2 11-13-2007 10:36 PM
numpy migration (also posted to numpy-discussion) Duncan Smith Python 3 04-25-2007 01:36 AM
Trouble with numpy-0.9.4 and numpy-0.9.5 drife Python 1 03-01-2006 05:59 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57