You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are cases where keys of python dictionaries may need aliases. When two keys point to the same value, duplication can also be avoided with this feature.
How it is done currently:
foo= {
key1: "value",
key2: "value",
...
}
Here "value" is repeatedly used as value of the keys. When there are more keys with the same value, the more duplication occurs.
See the following syntax:
Conceptual syntax
foo= {
key1, key2, ...: "value"
}
Here, the duplication is less and the code looks cleaner. Do note that the punctuator , is just as per my concept. If it may hold conflicts with the item separators of dictionaries (which is also ,), another punctuator can be used instead. E.g: |, ;, +
Use cases
This feature can be extremely useful for libraries which tends to be user friendly.
In big projects, when there is a confusion of key names ("was that show or display?"), this feature helps to avoid scrolling all the way up.
When key names are long, this feature helps to also accept acronyms or short names.
I have opened just opened a topic at discuss.python.org, thank you for responding! I will make sure to follow the instructions you mentioned for future issues π€
Description
There are cases where keys of python dictionaries may need aliases. When two keys point to the same value, duplication can also be avoided with this feature.
How it is done currently:
Here "value" is repeatedly used as value of the keys. When there are more keys with the same value, the more duplication occurs.
See the following syntax:
Conceptual syntax
Here, the duplication is less and the code looks cleaner. Do note that the punctuator
,
is just as per my concept. If it may hold conflicts with the item separators of dictionaries (which is also,
), another punctuator can be used instead. E.g:|
,;
,+
Use cases
show
ordisplay
?"), this feature helps to avoid scrolling all the way up.Examples
The text was updated successfully, but these errors were encountered: