Anyone want to critique this program?

Ben Finney ben+python at benfinney.id.au
Sun Jul 3 17:37:01 EDT 2011


John Salerno <johnjsal at gmail.com> writes:

> On Jul 2, 10:02 pm, Chris Angelico <ros... at gmail.com> wrote:
>
> > > game_information = '***Chutes and Ladders***\nUp to four (4) players
> > > may play.\n'\
> > >                   'There are 90 spaces on the board. '\
> > >                   'The player to reach space 90 first wins.'
> >
> > I'd do this with a triple-quoted string - it'll simply go across multiple lines:
> > game_information = """***Chutes and Ladders***
> > Up to four (4) players may play.
> > There are 90 spaces on the board.
> > The player to reach space 90 first wins."""
>
> Yeah, I considered that, but I just hate the way it looks when the
> line wraps around to the left margin.

    import textwrap

    game_information = textwrap.dedent("""\
        ***Chutes and Ladders***
        Up to four (4) players may play.
        There are 90 spaces on the board.
        The player to reach space 90 first wins.
        """)

-- 
 \      “Nothing is more sacred than the facts.” —Sam Harris, _The End |
  `\                                                   of Faith_, 2004 |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list