John J. Lee wrote:
> Peter Otten <[EMAIL PROTECTED]> writes:
> [...]
>   
>> def f(s):
>>     return (s,)
>>     
>
> Forgive me if this is a stupid question, but: What purpose does
> function f serve?
>
>
> John
>   

Well, it has nothing to do with the unicode bit that came before it.  It
just takes an argument, and wraps it in a 1-tuple.  Guessing by the
argument of "s", that argument is expected to be a string.

One use I can think of is that sometimes you'll find a function that
returns a string or a list or tuple of strings. If you want to pass that
result on to a for loop, and only loop once on the string (instead of
looping on each letter of the string), you might want to wrap it in a
tuple or a list before passing it to the loop.

Cheers,
Cliff


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to