Re: Tuple passed to function recognised as string

2009-03-18 Thread Scott David Daniels
Mike314 wrote: (paraphrased) >>> test_func(val=('val1')) >>> test_func(val=('val1', 'val2')) The output is quite different. Why I have string in the first case? More natural English: "Why do I get string in the first case?" (X) is the same as X (parentheses are for grouping), to get a singl

Tuple passed to function recognised as string

2009-03-18 Thread R. David Murray
Mike314 wrote: > Hello, > >I have following code: > > def test_func(val): > print type(val) > > test_func(val=('val1')) > test_func(val=('val1', 'val2')) > > The output is quite different: > > > > > Why I have string in the first case? Because in Python the syntactic element that

Re: Tuple passed to function recognised as string

2009-03-18 Thread Terry Reedy
Mike314 wrote: Hello, I have following code: def test_func(val): print type(val) test_func(val=('val1')) test_func(val=('val1', 'val2')) The output is quite different: Why I have string in the first case? Because () == . Perhaps you meant ('val1',). "Parenthesized forms A parent

Re: Tuple passed to function recognised as string

2009-03-18 Thread Albert Hopkins
On Wed, 2009-03-18 at 16:58 -0700, Mike314 wrote: > Hello, > >I have following code: > > def test_func(val): > print type(val) > > test_func(val=('val1')) > test_func(val=('val1', 'val2')) > > The output is quite different: > > > > > Why I have string in the first case? You could h

Re: Tuple passed to function recognised as string

2009-03-18 Thread MRAB
Mike314 wrote: Hello, I have following code: def test_func(val): print type(val) test_func(val=('val1')) test_func(val=('val1', 'val2')) The output is quite different: Why I have string in the first case? It's the comma that makes the tuple, except for one special case: the empty

Tuple passed to function recognised as string

2009-03-18 Thread Mike314
Hello, I have following code: def test_func(val): print type(val) test_func(val=('val1')) test_func(val=('val1', 'val2')) The output is quite different: Why I have string in the first case? Thanks. -- http://mail.python.org/mailman/listinfo/python-list