On 18/03/19 6:05 AM, Mats Wichmann wrote:
On 3/16/19 11:39 AM, Valerio Pachera wrote:
Consider this:
import collections
d = OrderedDict(a='hallo', b='world')
I wish to get a single string like this:
'a "hallo" b "world"'
Notice I wish the double quote to be part of the string.
In other words I w
On 3/16/19 11:39 AM, Valerio Pachera wrote:
> Consider this:
>
> import collections
> d = OrderedDict(a='hallo', b='world')
>
> I wish to get a single string like this:
>
> 'a "hallo" b "world"'
>
> Notice I wish the double quote to be part of the string.
> In other words I want to wrap the val
On March 16, 2019 5:57:23 PM MDT, Alan Gauld via Tutor wrote:
>On 16/03/2019 18:44, Peter Otten wrote:
>>
>> In Python 3.6 and above you can use f-strings:
>>
> d = dict(a="hello", b="world")
> " ".join(f'{k} "{v}"' for k, v in d.items())
>> 'a "hello" b "world"'
>
>Cool, I'd missed f-str
On 16/03/2019 18:44, Peter Otten wrote:
>
> In Python 3.6 and above you can use f-strings:
>
d = dict(a="hello", b="world")
" ".join(f'{k} "{v}"' for k, v in d.items())
> 'a "hello" b "world"'
Cool, I'd missed f-strings. Time for some reading
Thanks Peter,
--
Alan G
Author of th
On 2019-03-16 10:39, Valerio Pachera wrote:
Consider this:
import collections
d = OrderedDict(a='hallo', b='world')
I wish to get a single string like this:
'a "hallo" b "world"'
Notice I wish the double quote to be part of the string.
In other words I want to wrap the value of a and b.
I wa
Valerio Pachera wrote:
> Consider this:
>
> import collections
> d = OrderedDict(a='hallo', b='world')
>
> I wish to get a single string like this:
>
> 'a "hallo" b "world"'
>
> Notice I wish the double quote to be part of the string.
> In other words I want to wrap the value of a and b.
>
>
On 16/03/2019 17:39, Valerio Pachera wrote:
> I wish to get a single string like this:
>
> 'a "hallo" b "world"'
>
> Notice I wish the double quote to be part of the string.
> In other words I want to wrap the value of a and b.
When dealing with string layouts I tend to go to
string formatting.