[Python-ideas] Outside the box string formatting idea
Rob Cliffe
rob.cliffe at btinternet.com
Mon Aug 10 03:11:52 CEST 2015
On 10/08/2015 00:08, Ron Adam wrote:
>
>
>
> There are actually too parts...
>
> (% ...) Handles implicit concatination and string conversion.
>
> And {expr format} handles the formatting, inside (% ...) context only.
>
> So these only work in string format expressions, just like special
> syntax for comprehensions only works in comprehensions.
>
> As I suggested, I think it's the closest you can get and still not put
> the expressions into the strings.
>
> Comma's could be used to separate things, but it's not that much of a
> stretch to go from ....
>
> 'a' 'b' --> 'ab'
>
> to
> a = 'a'
> b = 'b'
> (% a b) --> 'ab'
>
> But we could have...
>
> (% a, b) If that seems more pythonic.
>
How does this gain over
def f(*args): return ''.join(args)
a='a'
b='b'
f(a, b)
Rob Cliffe
More information about the Python-ideas
mailing list