[Tutor] outputting long lines
Gerrit Holl
gerrit@nl.linux.org
Sat Mar 8 12:41:02 2003
Paul Tremblay schreef op zaterdag 8 maart om 07:22:14 +0000:
> Is there a tecnique for printing out long lines that span more than the
> length of your script?
>
> For example, I am trying to output this line:
>
> 1 if self.__token_info == 'cw<nt<type______':
> 2 self.__write_to_foot_obj.write('\
> 3 mi<dv<op<footnote<at<num>%s' % self.__footnote_count)
>
> My output is:
>
> mi<dv<op<footnote<at<num>2
>
> I don't want this huge space at the beginning. I want:
>
> mi<dv<op<footnote<at<num>2
>
> There are ugly ways to achieve what I want. I could output the text with
> several write lines. I could get rid of the space in line 3 above. But I
> was thinking there is probably an easeir and more elegant solution.
You can also do:
67 >>> if True:
67 ... if True:
67 ... if True: # 3 levels indented
67 ... sys.stdout.write("""
67 ... I want
67 ... to write
67 ... a text
67 ... spanning
67 ... multiple
67 ... lines!""")
yours,
Gerrit.
--
Asperger Syndroom - een persoonlijke benadering:
http://people.nl.linux.org/~gerrit/
Het zijn tijden om je zelf met politiek te bemoeien:
http://www.sp.nl/