Issue2817
Created on 2008-05-11 13:16 by chester, last changed 2008-05-11 18:51 by chester.
|
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) |
Date: 2008-05-11 13:18 |
|
But we need parentheses for grouping!
|
|
msg66634 - (view) |
Author: Georg Brandl (georg.brandl) |
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) |
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.
|
|
| Date |
User |
Action |
Args |
| 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 | |
|