[issue44190] Dictionary assignment shorthand

2021-05-21 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44190] Dictionary assignment shorthand

2021-05-20 Thread Christian Heimes


Christian Heimes  added the comment:

Your proposal is not possible in Python. The object does not know under which 
variable names it is accessible. The closest you can get is this:

>>> dict(
... foo="bar"
... )
{'foo': 'bar'}

--
nosy: +christian.heimes

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44190] Dictionary assignment shorthand

2021-05-20 Thread David Hariri


New submission from David Hariri :

In some languages, one may declare a dictionary's key and its value like so:

```
foo = "bar"

my_dict = { foo }
>> { "foo" : "bar" }
```

In Python, one must instead write:

```
foo = "bar"

my_dict = {
"foo": foo
}
>> { "foo" : "bar" }
```

I humbly suggest this change as a QoL improvement for those who work with 
dictionaries all day.

--
messages: 394027
nosy: davidhariri
priority: normal
severity: normal
status: open
title: Dictionary assignment shorthand
type: enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com