Cast list of objects to list of strings

bukzor workitharder at
Mon Jun 2 22:52:32 CEST 2008

I have this function:

def write_err(obj):
     from sys import stderr

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 property that the function works on any object. What's
the simplest way to fix this? In essence, I need to cast a list of
objects to a list of strings. I'd like to do just "str(objs)" but that
(obviously) doesn't quite do what I need.

More information about the Python-list mailing list