I was working on some code when I realized I had changed a mutli-member tuple to a single-value string but left the parens wrapped around the string, and was surprised that I hadn't encountered any problems when I realized I had left in the parens.
Simple question, why are strings inside of parens treated as strings and not tuples?
I understand this:
>>> foo= 'bar'
>>> type(foo)
<class 'str'>
And I understand this:
>>> foo = ('bar',)
>>> type(foo)
<class 'tuple'>
And this, of course:
foo = ('bar', 'baz')
>>> type(foo)
<class 'tuple'>
But I don't understand this:
>>> foo = ('bar')
>>> type(foo)
<class 'str'>
Why is ('bar')
a string and not a tuple? I know adding the trailing ,
makes it a tuple, but for what reason was that design decision made?