[Python-Dev] repr vs. str and locales again
Ka-Ping Yee
ping@lfw.org
Fri, 19 May 2000 10:04:18 -0700 (PDT)
On Fri, 19 May 2000, Ka-Ping Yee wrote:
>
> Changing the behaviour of repr() (a function that internally
> converts data into data)
Clarification: what i meant by the above is, repr() is not
explicitly an input or an output function. It does "some
internal computation".
Here is one alternative:
repr(obj, **kw): options specified in kw dict
push each element in kw dict into sys.repr_options
now do the normal conversion, referring to whatever
options are relevant (such as "locale" if doing strings)
for looking up any option, first check kw dict,
then look for sys.repr_options[option]
restore sys.repr_options
This is ugly and i still like printon/printout better, but
at least it's a smaller change and won't prevent the implementation
of printon/printout later.
This suggestion is not thread-safe.
-- ?!ng
"Simple, yet complex."
-- Lenore Snell