On May 6, 4:04 pm, Mel Wilson <[EMAIL PROTECTED]> wrote: > Vyacheslav Maslov wrote: > > So, the main question is why using syntax like [X] python constuct list > > with > > one item, but when i try to construct tuple with one item using similar > > syntax (X) python do nothing? > > Because `(` and `)` are used in expressions to bracket sub-expressions. > > a = (4 + 3) * 2 > > means: add 4 to 3, multiply the sum by 2. It can't mean: make a tuple > containing 7 and extend it to 7,7 . > > The real constructor for tuples is `,`. When you see parens around > tuple creation they're there to bracket the sub-expression that > creates the tuple. You see new tuples without parens all the time: > > for i, thing in enumerate (things): ... > > starter, main_course, dessert, beverage = order_meal (*hunger) > > etc. > > Mel. > If it's the comma that makes the tuple, then wouldn't [1, 2] make a 2- tuple in a list, ie == [(1, 2)]? Hmm...
-- http://mail.python.org/mailman/listinfo/python-list