Python 2.1 and Unicode

Dale Strickland-Clark dale at out-think.NOSPAMco.uk
Wed Jan 31 12:37:41 EST 2001


"Alex Martelli" <aleaxit at yahoo.com> wrote:

>"Dale Strickland-Clark" <dale at out-think.NOSPAMco.uk> wrote in message
>news:hpse7tc1h31hosvt4ojeu419c531mm76ij at 4ax.com...
>    [snip]

>You may put something like this in your site-configuration script[s]:
>
>import __builtin__
>def astr(x,str=__builtin__.str):
>    try: return str(x)
>    except UnicodeError:
>        return x.encode('latin1','ignore')
>__builtin__.str = astr
>
>to replace the built-in str with a "more forgiving" one to your
>taste.  This won't help with other implicit stringifications,
>though -- for those, setting the default encoding (again in your
>site configuration) may be best, but I don't think that, this
>way, you can specify 'ignore' rather than 'strict' as the default.
>
>
>Alex
>
>
Thanks, again, Alex.

This is where you realise that you still have a lot to learn. 

Interesting idea. I understand what you're doing but not the principles of getting into
"__builtin__"

I'm not familiar with the site configuration stuff. Could I also use this for identifying our own
module library?

Where's it documented?
--
Dale Strickland-Clark
Out-Think Ltd
Business Technology Consultants



More information about the Python-list mailing list