By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,711 Members | 1,309 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,711 IT Pros & Developers. It's quick & easy.

NumPy chararray and whitespace

P: n/a
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
Jun 27 '08 #1
Share this Question
Share on Google+
1 Reply

P: n/a
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

Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.