"1,+2,", but not "(1,)+2,"
Python
python at python.invalid
Fri Jul 31 09:43:18 EDT 2020
- Previous message (by thread): "1,+2,", but not "(1,)+2,"
- Next message (by thread): "1,+2,", but not "(1,)+2,"
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Stefan Ram wrote:
> Jon Ribbens <jon+usenet at unequivocal.eu> writes:
>> On 2020-07-31, Stefan Ram <ram at zedat.fu-berlin.de> wrote:
>>> You can write
>>> |>>> 1,+2,
>>> |(1, 2)
>>> , but not
>>> |>>> (1,)+2,
>>> |TypeError: can only concatenate tuple (not "int") to tuple
>>> . Why? (Python 3.9)
>> For the obvious reason, as indicated by the error message?
>> What are you expecting these expressions to mean?
>
> In »1,+2,«, the right operand »2,« obviously is interpreted
> to be a 1-tuple.
Nope. The right operant is 2 not 2, and is interpreted as an int.
- Previous message (by thread): "1,+2,", but not "(1,)+2,"
- Next message (by thread): "1,+2,", but not "(1,)+2,"
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Python-list
mailing list