F. Petitjean wrote:
Le Tue, 15 Mar 2005 23:21:02 -0800, Michael Spencer a écrit :



def output(seq, linelength = 60): if seq: iterseq = iter(seq) while iterseq: print "".join(islice(iterseq,linelength))

I suppose you mean : print "".join( str(item) for item in islice(iterseq, linelength) ) # using python 2.4 genexp

No, as written, given the seq is a sequence of single character strings already (changing the signature might clarify that):

def output(charseq, linelength = 60):
    if charseq:
        iterseq = iter(charseq)
        while iterseq:
            print "".join(islice(iterseq,linelength))

 >>> output("*" * 120, 40)
 ****************************************
 ****************************************
 ****************************************
 >>> output(['*'] * 120, 40)
 ****************************************
 ****************************************
 ****************************************
 >>>

Cheers
Michael

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

Reply via email to