UTF-8 characters in doctest
J. Cliff Dyer
jcd at sdf.lonestar.org
Thu Sep 20 23:14:04 EDT 2007
More information about the Python-list mailing list
Thu Sep 20 23:14:04 EDT 2007
- Previous message (by thread): UTF-8 characters in doctest
- Next message (by thread): UTF-8 characters in doctest
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
J. Cliff Dyer wrote: > John J. Lee wrote: > >> Peter Otten <__peter__ at web.de> 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 (replying to my own post) Sorry. Itchy trigger finger and tired brain. I didn't read the whole context of the thread. Dunno what it's doing here. Forcing __repr__ to be called on a print statement? Funny way to do that. Like I said, I don't know, so I'll leave it to someone else to say. Cheers, Cliff
- Previous message (by thread): UTF-8 characters in doctest
- Next message (by thread): UTF-8 characters in doctest
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list