On Thu, Oct 18, 2012 at 10:11 PM, boB Stepp <robertvst...@gmail.com> wrote: >>>> if zero: > print(zero) > else: > print(phrase) > > Is there some special way for typing in multiline blocks of code into > the shell in IDLE? The above works, but it bothers me that "else" does > not line up with "if". Also, in the IDLE shell the "p" in "print" > actually lines up under the "e" in "zero". However when I copied from > IDLE and pasted into gmail, this alignment was changed. I am guessing > it is because gmail is not using a fixed-width font. And I have yet to > figure out how to get it to use one when in plaintext mode.
You're right that the alignment changed because of the font rendering of the tab character. In Firefox I use the following to get a monospace font in Gmail: http://userstyles.org/styles/15618/gmail-monospace-font-for-body-messages-textarea As to your main question, I use exec: >>> zero, phrase = '', 'spam' >>> exec(''' if zero: print(zero) else: print(phrase) ''') spam _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor