I've seen this proposed before, and I personally would love this, but my guess is that it breaks too much code for too little gain. On Wednesday, May 21, 2014 12:33:30 PM UTC-4, Frédéric Legembre wrote:
Now | Future | ---------------------------------------------------- () | () | empty tuple ( 1, 2, 3 ) [] | [] | empty list [ 1, 2, 3 ] set() | {} | empty set { 1, 2, 3 } {} | {:} | empty dict { 1:a, 2:b, 3:c }
2014-06-10 8:15 GMT+02:00 Neil Girdhar <mistersheik@gmail.com>:
I've seen this proposed before, and I personally would love this, but my guess is that it breaks too much code for too little gain.
On Wednesday, May 21, 2014 12:33:30 PM UTC-4, Frédéric Legembre wrote:
Now | Future | ---------------------------------------------------- () | () | empty tuple ( 1, 2, 3 ) [] | [] | empty list [ 1, 2, 3 ] set() | {} | empty set { 1, 2, 3 } {} | {:} | empty dict { 1:a, 2:b, 3:c }
Your guess is right. It will break all Python 2 and Python 3 in the world. Technically, set((1, 2)) is different than {1, 2}: the first creates a tuple and loads the global name "set" (which can be replaced at runtime!), whereas the later uses bytecode and only store values (numbers 1 and 2). It would be nice to have a syntax for empty set, but {} is a no-no. Victor
On Wednesday, May 21, 2014 12:33:30 PM UTC-4, Frédéric Legembre wrote:
Now | Future | ---------------------------------------------------- () | () | empty tuple ( 1, 2, 3 ) [] | [] | empty list [ 1, 2, 3 ] set() | {} | empty set { 1, 2, 3 } {} | {:} | empty dict { 1:a, 2:b, 3:c }
This is *exactly* what I would want if I were designing a language from scratch. It's obvious, readable, etc. However, it also breaks every single instance of 'newdict = {}' in Python code, which is a very common idiom. Unfortunately, I don't really like the proposed empty-set literal proposed in the thread: '{,}'. It saves two characters over 'set()', but is not intuitive to me. -- Keeping medicines from the bloodstreams of the sick; food from the bellies of the hungry; books from the hands of the uneducated; technology from the underdeveloped; and putting advocates of freedom in prisons. Intellectual property is to the 21st century what the slave trade was to the 16th.
participants (3)
-
David Mertz
-
Neil Girdhar
-
Victor Stinner