[Python-ideas] Unpack of sequences
Guido van Rossum
guido at python.org
Wed Aug 29 23:30:42 CEST 2012
On Wed, Aug 29, 2012 at 2:19 PM, Alexander Belopolsky
<alexander.belopolsky at gmail.com> wrote:
> On Wed, Aug 29, 2012 at 4:45 PM, Guido van Rossum <guido at python.org> wrote:
>> But {a, b, c} doesn't look like a dict.
>
> locals().update(m) does not look like a dict either, but many people
> expect it to work and get bitten when it does not.
>
>> Please give it up.
>
> Do you ask to give up the {a, b, c} = idea or any ideas that import
> mappings into local variables?
The latter. (Or attributes to locals.)
> For example some abuse of the with
> statement would allow
>
> with m in a, b, c:
> # a, b, and c are local here
>
> I am not really proposing this, just giving an example for the range
> of possibilities. I am sure an acceptable syntax can be found if DRY
> is considered important enough, but if any automation of
>
> a = m['a']
> b = m['b']
> c = m['c']
>
> is deemed to be an anti-pattern, then this thread is better to stop.
--
--Guido van Rossum (python.org/~guido)
More information about the Python-ideas
mailing list