'generating' a print statement
Patrick Vrijlandt
vrijlandt.p at bethesda.nl
Thu May 8 13:00:11 EDT 2003
I thought of:
print " ".join([str(s) for s in temp])
> > I'm trying to avoid using a 'kluge' construct like;
> > for item in range(len(temp)):
> > if len(temp) == 5:
> > print "%s %s %s %s %s" %
> > (temp[0],temp[1],temp[2],temp[3],temp[4])
> > elif len(temp) == 4:
> > print "%s %s %s %s" % ((temp[0],temp[1],temp[2],temp[3])
> > elif len(temp) == 3:
> > print "%s %s %s" % (temp[0],temp[1],temp[2])
> > elif len(temp) == 2:
> > print "%s %s" % (temp[0],temp[1])
> > elif len(temp) == 1:
> > print "%s" % (temp[0])
--
Patrick Vrijlandt
More information about the Python-list
mailing list