Tuomas schrieb: > >>> def g(*arg): > ... return arg > ... > >>> g('foo', 'bar') > ('foo', 'bar') > >>> # seems reasonable > ... > >>> g(g('foo', 'bar')) > (('foo', 'bar'),) > >>> # not so good, what g should return to get rid of the outer tuple > > TV Use the following then: >>> g(*g('foo', 'bar')) ('foo', 'bar')
Otherwise, you would have to check if arg is a 1-tuple consisting of a tuple and "strip" it out then. e.g. >>> def g(*arg): ... return arg[0] if isinstance(arg[0], tuple) else arg ... >>> g('foo', 'bar') ('foo', 'bar') >>> g(g('foo', 'bar')) ('foo', 'bar') -- http://mail.python.org/mailman/listinfo/python-list