Reputation: 5480
Example:
regular_string = "%s %s" % ("foo", "bar")
result = {}
result["somekey"] = regular_string,
print result["somekey"]
# ('foo bar',)
Why result["somekey"]
tuple now not string?
Upvotes: 3
Views: 2705
Reputation: 3040
When you write
result["somekey"] = regular_string,
Python reads
result["somekey"] = (regular_string,)
(x,)
is the syntax for a tuple with a single element. Parentheses are assumed. And you really end up putting a tuple, instead of a string there.
Upvotes: 9