TypeError expected in an augmented assignment
candide
c.candide at laposte.net
Thu Jul 3 03:51:39 EDT 2014
> >>> seq = [1,2]
>
> >>> seq.extend((3,4))
OK, this feature is referenced in the Python Library reference here :
https://docs.python.org/3.2/library/stdtypes.html#typesseq-mutable
not thoroughly referenced but, anyway, referenced.
>
> >>> seq+= {5, 6} # the order of extending is not determined
>
> >>> seq
>
> [1, 2, 3, 4, 5, 6]
>
> >>>
Good and interesting observation. But I can't find out where this feature is referenced in the Language/Library Reference. Because, as my first post explains, augmented assignment performs the binary operation associated to the augmented assignment, cf.
https://docs.python.org/3.2/reference/simple_stmts.html#augmented-assignment-statements
so seq+= {5, 6} performs seq + {5, 6}, the later raising a TypeError.
More information about the Python-list
mailing list