New-style string formatting (Was: Re: Tuple "detection")

Gerrit Holl gerrit at nl.linux.org
Wed May 21 04:53:05 EDT 2003


[Gerrit Holl]
> > > > because the '%' is redundant; it's a much smaller change:

[Daniel Dittmar]
> > > redundant only for the common case of
> > > "string %s %s" % (value1, value2)
> > > but not for
> > > "string %s %s" % db.getRow ()

[Gerrit Holl]
> > This would become:
> > 
> > "string %s %s"(*db.getrow())

[Ian Bicking]
> Maybe you would be happy with the idea of using * and ** prefixes in
> literals (well, at least *), like:

This proposal doesn't require a syntax change, since it only adds
a __call__ method: the *t and **m syntax already exists for function
calls.

>   (a, *b, c) == (a,) + tuple(b) + (c,)

Hm, I'm not sure whether this proposal is completely sound.

> And possibly:
> 
>   {'a': b, **c} 
> meaning:
>   tmp = {'a': b}
>   tmp.update(c)

This looks good, however.

yours,
Gerrit.

-- 
121. If any one store corn in another man's house he shall pay him
storage at the rate of one gur for every five ka of corn per year. 
        -- Hammurabi, Code of Law
--
Asperger Syndroom - een persoonlijke benadering:
	http://people.nl.linux.org/~gerrit/
Het zijn tijden om je zelf met politiek te bemoeien:
	http://www.sp.nl/





More information about the Python-list mailing list