[Tutor] if you're interested in the code thus far...

Clayton Kirkwood crk at godblessthe.us
Sun Oct 26 20:32:53 CET 2014


Good eyes on the logic


!-----Original Message-----
!From: Tutor [mailto:tutor-bounces+crk=godblessthe.us at python.org] On
!Behalf Of Peter Otten
!Sent: Sunday, October 26, 2014 3:53 AM
!To: tutor at python.org
!Subject: Re: [Tutor] if you're interested in the code thus far...
!
!Clayton Kirkwood wrote:
!
!> for description_position, code_position in zip(description, code):
!>     description_position_len = len(description_position)
!>     current_output_pos += description_position_len
!>     if current_output_pos >= output_line_len:
!>         print(description_output_string)
!>         print(code_output_string)
!>         code_output_string=description_output_string=''
!>         current_output_pos=-1   #start new line

Changing this line to current_ouput_pos = description_position_len
I believe I was losing the next lines final field on each subsequent line
Thank-you

Clayton

!>
!>     description_output_string += '{:^}|'.format(description_position)
!>     code_output_string+='{0:^{1}}|'.format(code_position,
!> description_position_len)
!>
!>     current_output_pos+=1  #takes care of '|' at end of string
!
!If you want to ensure that the actual line length is never more than
!output_line_len -- the above doesn't do that.
!
!Hint: reconsider this line:
!
!>         current_output_pos=-1   #start new line
!
!
!> and a subset of output:
!
!Some pairs are not printed. Can you figure out which and why?
!
!_______________________________________________
!Tutor maillist  -  Tutor at python.org
!To unsubscribe or change subscription options:
!https://mail.python.org/mailman/listinfo/tutor





More information about the Tutor mailing list