Re: Cast list of objects to list of strings

2008-06-03 Thread jay graves
On Jun 2, 8:36 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > Still nitpicking: using a generator expression in this case has no > advantage. The first thing that str.join does is to create a list out of > its argument (unless it is already a list or a tuple). In fact, a list > comprehension

Re: Cast list of objects to list of strings

2008-06-02 Thread Gabriel Genellina
En Mon, 02 Jun 2008 18:56:08 -0300, jay graves <[EMAIL PROTECTED]> escribió: On Jun 2, 4:02 pm, Larry Bates <[EMAIL PROTECTED]> wrote: I think what you want is: def write_err(*args): from sys import stderr stderr.write("\n".join([str(o) for o in args])) Slight nitpick. If you are

Re: Cast list of objects to list of strings

2008-06-02 Thread bukzor
On Jun 2, 2:56 pm, jay graves <[EMAIL PROTECTED]> wrote: > On Jun 2, 4:02 pm, Larry Bates <[EMAIL PROTECTED]> wrote: > > > I think what you want is: > > def write_err(*args): > > from sys import stderr > > stderr.write("\n".join([str(o) for o in args])) > > Slight nitpick. If you are usi

Re: Cast list of objects to list of strings

2008-06-02 Thread Gary Herron
bukzor wrote: I have this function: def write_err(obj): from sys import stderr stderr.write(str(obj)+"\n") and I'd like to rewrite it to take a variable number of objects. Something like this: def write_err(*objs): from sys import stderr stderr.write(" ".join(objs)+"\n") b

Re: Cast list of objects to list of strings

2008-06-02 Thread jay graves
On Jun 2, 4:02 pm, Larry Bates <[EMAIL PROTECTED]> wrote: > I think what you want is: > def write_err(*args): > from sys import stderr > stderr.write("\n".join([str(o) for o in args])) Slight nitpick. If you are using version >= 2.4 you could use a generator expression instead of a list

Re: Cast list of objects to list of strings

2008-06-02 Thread Larry Bates
bukzor wrote: I have this function: def write_err(obj): from sys import stderr stderr.write(str(obj)+"\n") and I'd like to rewrite it to take a variable number of objects. Something like this: def write_err(*objs): from sys import stderr stderr.write(" ".join(objs)+"\n") b

Cast list of objects to list of strings

2008-06-02 Thread bukzor
I have this function: def write_err(obj): from sys import stderr stderr.write(str(obj)+"\n") and I'd like to rewrite it to take a variable number of objects. Something like this: def write_err(*objs): from sys import stderr stderr.write(" ".join(objs)+"\n") but I lose the pr