This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2008年05月11日 13:16 by chester, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Messages (5) | |||
|---|---|---|---|
| msg66626 - (view) | Author: Chester (chester) | Date: 2008年05月11日 13:16 | |
To create a tuple with one element, you need to do this: >>> my_tuple = (1,) # Note the trailing comma after the value 1 >>> type(my_tuple) <type 'tuple'> But if you do this >>> my_tuple = (1) >>> type(my_tuple) <type 'int'> you don't get a tuple. I thought that just putting a value inside ( ) would make a tuple. Apparently that is not the case. I hate ugly code so it would be clean if Python would convert anything put into ( ) to be a tuple, even if just one value was put in (without having to use that ugly looking comma with no value after it). |
|||
| msg66627 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2008年05月11日 13:18 | |
But we need parentheses for grouping! |
|||
| msg66634 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2008年05月11日 14:18 | |
That's an absolute no-starter. Not the parentheses make the tuple, the commas do. The empty tuple is the exception, not the rule. |
|||
| msg66645 - (view) | Author: Martin v. Löwis (loewis) * (Python committer) | Date: 2008年05月11日 16:50 | |
Just in case the previous comments aren't clear: Would you rather see py> (3+4)*5 35 or py> (3+4)*5 (7, 7, 7, 7, 7) |
|||
| msg66650 - (view) | Author: Chester (chester) | Date: 2008年05月11日 18:51 | |
Martin I see the point now. I appologize for not having the clear head of seeing the possible damage that my feature request would make. I take my request back. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:34 | admin | set | github: 47066 |
| 2008年05月11日 18:51:24 | chester | set | messages: + msg66650 |
| 2008年05月11日 16:50:36 | loewis | set | nosy:
+ loewis messages: + msg66645 |
| 2008年05月11日 14:18:41 | georg.brandl | set | status: open -> closed resolution: rejected messages: + msg66634 nosy: + georg.brandl |
| 2008年05月11日 13:18:11 | benjamin.peterson | set | nosy:
+ benjamin.peterson messages: + msg66627 |
| 2008年05月11日 13:16:16 | chester | create | |