Optional code segment delimiter?

Jason tenax.raccoon at gmail.com
Sat Dec 29 13:27:33 EST 2007


On Dec 29, 10:20 am, xkenneth <xkenn... at gmail.com> wrote:
> Is it possible to use optional delimiters other than tab and colons?
>
> For example:
>
>      if this==1 {
>           print this
>      }

Certainly, it's very possible.  Here's how to do it:
  1. Download the python source code (easy)
  2. Modify the parser as needed (hard)
  3. Re-apply your patches to each additional version of Python that
gets released (hard)

Alternatively:
  1. Write a script in regular Python/Perl/Ruby/Bash-script to convert
your code into real Python.  (Bonus: This may give you the write-
compile-run cycle that some C/C++ programmers desperately crave!)

Or, another alternative:
  1. Get used to using indention.
  2. Use a Python-aware editor to automatically add the proper number
of indenting spaces for you.
  3. If you feel the urge to use braces, write in Java until
thoroughly sick of them.  If you don't feel the bile rising in your
throat, it's too soon to come back to Python.

>
> And is there an alternate delimiter for statements other than the
> newline?
>
> print this;print that; #for example

>>> print "This" ; print "That"
This
That
>>>

That wasn't so hard, now was it?  Just remember that clarity beats
compactness any day.  The semicolon doesn't even save you any
keystrokes if you're using a Python-aware editor.  People who feel the
need to write a program on a single line will be rightfully mocked by
other Pythonistas.  How is:

    print "This"; print "That"

better than:

    print "This"
    print "That"

I know which one is easier for me to read.

>
> I know I'll probably get yelled at for this question, but I would just
> like to know.
>
> Regards,
> Ken

No yelling, but a little snickering from some of us.

  --Jason



More information about the Python-list mailing list