[Fwd: [Matplotlib-users] Feature request: make labels accept non-string arguments]

In response to the feature request:

Does anyone see any disadvantage to making Text.__init__ and Text.set_text() either try to call the __str__ method, or use the str() builtin, if passed an argument that is not a string? Maybe there is no need to even check--just automatically use str(arg)? Offhand, this looks to me like it would provide a gain in convenience and intuitiveness with no pain.

Eric

[Matplotlib-users] Feature request: make labels acceptnon-stringarguments (4.23 KB)

My concern is that we don't break unicode support , so if you come up
with a solution that supports calling str but doesn't break unicode,
it's fine by me

In [2]: x = unicode('D\351velopp\351s et fabriqu\351s', 'latin-1')

In [3]: x
Out[3]: u'D\xe9velopp\xe9s et fabriqu\xe9s'

In [4]: str(x)

···

On 3/17/07, Eric Firing <efiring@...229...> wrote:

In response to the feature request:

Does anyone see any disadvantage to making Text.__init__ and
Text.set_text() either try to call the __str__ method, or use the str()
builtin, if passed an argument that is not a string? Maybe there is no
need to even check--just automatically use str(arg)? Offhand, this
looks to me like it would provide a gain in convenience and
intuitiveness with no pain.

---------------------------------------------------------------------------
exceptions.UnicodeEncodeError Traceback (most
recent call last)

/Users/jdhunter/<ipython console>

UnicodeEncodeError: 'ascii' codec can't encode character '\ue9' in
position 1: ordinal not in range(128)

John Hunter wrote:

In response to the feature request:

Does anyone see any disadvantage to making Text.__init__ and
Text.set_text() either try to call the __str__ method, or use the str()
builtin, if passed an argument that is not a string? Maybe there is no
need to even check--just automatically use str(arg)? Offhand, this
looks to me like it would provide a gain in convenience and
intuitiveness with no pain.

My concern is that we don't break unicode support , so if you come up
with a solution that supports calling str but doesn't break unicode,
it's fine by me

In [2]: x = unicode('D\351velopp\351s et fabriqu\351s', 'latin-1')

In [3]: x
Out[3]: u'D\xe9velopp\xe9s et fabriqu\xe9s'

Looks like the simplest thing is

arg = '%s' % (arg,)

I'll give that a try.

Eric

···

On 3/17/07, Eric Firing <efiring@...229...> wrote:

In [4]: str(x)
---------------------------------------------------------------------------
exceptions.UnicodeEncodeError Traceback (most
recent call last)

/Users/jdhunter/<ipython console>

UnicodeEncodeError: 'ascii' codec can't encode character '\ue9' in
position 1: ordinal not in range(128)

I'm trying to build matplotlib and basemap on a solaris box using the latest SVN. My python, qt, tk, etc are all installed in a build directory ($TOOLS). Under linux, the build goes fine and everything works great. However, under solaris, both matplotlib and basemap have link errors that say they can't find the python shared library which is at $TOOLS/lib. Under linux, this shows up in the link line as -L$TOOLS/lib but is missing on solaris.

I'm trying to figure out how I can add -L$TOOLS/lib to the link line. For matplotlib, I was able to just hand copy the error message to the command line, add -L$TOOLS/lib, and rerun 'python setup.py build' to get it to work. This doesn't work for basemap though as it seems to generate some intermediate files that are needed.

I edited setup.py to do this:

import sys
basedir[sys.platform] = [ os.environ['TOOLS' ] ]

which seems to have worked on linux but doesn't seem to work on solaris. I google'ed to try and figure out how to add a link option using distutils and found something that said to do this:

python setup.py build build_ext -n -L$TOOLS/lib

but that doesn't build all the necessary components so my installation ends up not working.

Does anyone know an easy way to add this link dir to the distutils build?

Thanks,
Ted
Ted Drain Jet Propulsion Laboratory ted.drain@...179...