[Python-Dev] Triple-quoted strings and indentation (original) (raw)
Terry Reedy tjreedy at udel.edu
Wed Jul 6 07:36:01 CEST 2005
- Previous message: [Python-Dev] Triple-quoted strings and indentation
- Next message: [Python-Dev] Triple-quoted strings and indentation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Andrew Durdin" <adurdin at gmail.com> wrote in message news:59e9fd3a0507052116307e4d84 at mail.gmail.com...
In general, I find triple-quoted strings to be very handy, particularly for standalone scripts. However, the fact that they have to be written in the left-hand column to avoid leading whitespace really grates, particularly when they're nested within a block or two -- it's a wart:
try: options, args = getopt.getopt(sys.argv[1:], "cf:s") except getopt.GetoptError: print """Usage: dostuff Options: -c - blah blah -f - do stuff with file "filename" -s - more blah""" sys.exit(1) This really makes the code hard to read, as the indentation is all mixed up (visually). I have written a patch that changes the way triple-quoted strings are scanned so that leading whitespace is ignored in much the same way that pep 257 handles it for docstrings. Largely this was for a learning experience in hacking the parser, but it would be very nice IMO if something of this sort could be implemented in a future version of Python. To this end, I have sketched out a draft PEP (which was itself a good learning exercise in thinking out the issues of such a change). Should I post it here for discussion? Andrew
Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/python-python-dev%40m.gmane.org
- Previous message: [Python-Dev] Triple-quoted strings and indentation
- Next message: [Python-Dev] Triple-quoted strings and indentation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]