Mutable strings

Alex Martelli aleaxit at yahoo.com
Mon Sep 22 15:26:56 CEST 2003


On Monday 22 September 2003 02:50 pm, Jeff Epler wrote:
> On Mon, Sep 22, 2003 at 12:31:58PM +0000, Alex Martelli wrote:
> > But, there IS one!  So, hat's wrong with it...?!
>
> People seem to love to have literals for things.  Otherwise, they feel
> that a type is second-class.

Sure.  I have no problem deeming "mutable strings" (array of bytes)
to be "second-class" in some vague sense, since their use is so rare
and the need for literals of that type even rarer; lacking literals for,
e.g., sets.Set "troubles" me far more;-).

I do keep daydreaming of some "user-defined semiliteral syntax"
such as, e.g. <identifier>{<balanced-parentheses tokens>} to
result in a call to (e.g.) <identifier>.__literal__ with a list (or other
sequence) of tokens as the argument, returning whatever that
call returns.  But perhaps it isn't that good an idea after all (it
does imply the __literal__ classmethod or staticmethod doing
some sort of runtime compilation and execution of those tokens,
and opens the doors to the risk of some seriously nonPythonic
syntax for such "literals-initializers").


Alex






More information about the Python-list mailing list