[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Optional code segment delimiter?

xkenneth

12/29/2007 5:20:00 PM

Is it possible to use optional delimiters other than tab and colons?

For example:

if this==1 {
print this
}

And is there an alternate delimiter for statements other than the
newline?

print this;print that; #for example


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

Regards,
Ken
4 Answers

Marc 'BlackJack' Rintsch

12/29/2007 5:25:00 PM

0

On Sat, 29 Dec 2007 09:20:00 -0800, xkenneth wrote:

> Is it possible to use optional delimiters other than tab and colons?

No.

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

Yes.

But both are reasons to yell at you. ;-)

Ciao,
Marc 'BlackJack' Rintsch

Jason

12/29/2007 6:28:00 PM

0

On Dec 29, 10:20 am, xkenneth <xkenn...@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

Matt Nordhoff

12/29/2007 6:41:00 PM

0

xkenneth wrote:
> Is it possible to use optional delimiters other than tab and colons?
>
> For example:
>
> if this==1 {
> print this
> }

<http://timhatch.com/projects/pyb...

Heheheh..

<snip>
--

Dan Bishop

12/29/2007 8:32:00 PM

0

On Dec 29, 12:41 pm, Matt Nordhoff <mnordh...@mattnordhoff.com> wrote:
> xkenneth wrote:
> > Is it possible to use optional delimiters other than tab and colons?
>
> > For example:
>
> > if this==1 {
> > print this
> > }
>
> <http://timhatch.com/projects/pyb...
>
> Heheheh..

Wow! I never thought of (ab)using encodings like that. And sure
enough, it's perfectly legal to write:


# -*- encoding: rot-13 -*-

cevag h"Uryyb, jbeyq!"