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 dict

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

2016-10-25 Thread Michel Desmoulin
Le 25/10/2016 à 22:27, Paul Moore a écrit : 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) Avoi

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) Avoiding having to repeat the vari

[Python-ideas] f-string, for dictionaries

2016-10-25 Thread Michel Desmoulin
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 dictionaries: >>> foo = 1 >>> bar = 2 >>> {:bar, :foo} {'bar': 1, 'foo', 2} And a