trouble understanding None

Terry Reedy tjreedy at udel.edu
Wed Nov 12 17:38:00 EST 2003


"Peter Otten" <__peter__ at web.de> wrote in message
news:bot32t$mf3$00$1 at news.t-online.com...
> import sys
> charset = { "S":
>     [
>         "  ________  ",
>         " /--------\ ",
>         "//        \\\\",
>         "||        ^^",
>         "||          ",
>         r"\\________  ",
>         r" \--------\ ",
>         "          \\\\",
>         "          ||",
>         "_         ||",
>         r"\\________//",
>         r" \--------/ ",
>     ],

Unless the OP actually needs a list of lines, I think I would make the
value corresponding to each letter one string with embedded newlines:
bigletter = {
'S': r'''
  ________
 /--------\
//        \\
||        ^^
||
\\________
 \--------\
          \\
          ||
_         ||
\\________//
 \--------/'''

# etc
}
print bigletter['S']

This is very easy to edit (with a fixed pitch editor), aud to use.

>>> print bigletter['S']

  ________
 /--------\
//        \\
||        ^^
||
\\________
 \--------\
          \\
          ||
_         ||
\\________//
 \--------/

The only real problem is (maybe) the extra newline at the beginning of
the file, which makes the first line line-up with the rest.  The raw
mode input makes it impossible (as far as I know) to escape it (with
the usual '\', which gets printed instead).  So one could either
postprocess the dict to slice all values or delete the initial newline
in the source code after getting the letter right.

Terry J. Reedy






More information about the Python-list mailing list