Lists And Missing Commas

Tim Daneliuk info at tundraware.com
Mon Dec 23 19:48:52 EST 2019


If I do this:

    foo = [ "bar", "baz" "slop", "crud" ]

Python silently accepts that and makes the middle term "bazslop".

BUT, if I do this:

    foo = [ "bar", "baz" 1, "crud" ]

or this:

    foo = [ "bar", 2 1, "crud" ]

The interpreter throws a syntax error.

This is more of an intellectual curiosity than anything else, but why do strings silently
concatenate like that, while all other case blow up with an error.  i.e., What is about
the language the promotes this behavior.  At first blush, it seems inconsistent, but what
do I know ...






More information about the Python-list mailing list