[Tutor] Dictionaries of Tuples of Strings
Tim Golden
mail at timgolden.me.uk
Fri Feb 23 22:24:29 CET 2007
Luke Paireepinart wrote:
> That's because you can't make tuples of single values.
> Parenthesis are ways of controlling order of operation.
> They don't create tuples unless there's more than one value.
> Think of it like this:
> a TUple needs TWO elements or more.
> Solution:
> use lists. They can contain single elements.
Don't know where you got that one from:
<code>
t = (1,)
type (t)
</code>
In fact, in a certain way, it's the comma which makes the tuple.
Brackets are only needed in some circs to disambiguate (eg in
parameter lists to functions)
<code>
t = 1,
type (t)
</code>
TJG
More information about the Tutor
mailing list