Re: [Python-ideas] f-string, for dictionaries

2016-10-26 Thread Steven D'Aprano
On Tue, Oct 25, 2016 at 09:11:06PM +0200, Michel Desmoulin wrote: > We have a syntax to create strings with variables automatically inferred > from its context: > > >>> name = "Guido" > >>> print(f'Hello {name}') > Hello Guido > Similarly, I'd like to suggest a similar feature for building

Re: [Python-ideas] f-string, for dictionaries

2016-10-25 Thread Paul Moore
On 25 October 2016 at 20:11, Michel Desmoulin wrote: > Similarly, I'd like to suggest a similar feature for building dictionaries: > foo = 1 bar = 2 {:bar, :foo} > {'bar': 1, 'foo', 2} I don't see a huge advantage over >>> dict(foo=foo, bar=bar)