Favorite non-python language trick?

Doug Schwarz see at sig.for.address.edu
Fri Jun 24 10:34:35 EDT 2005


In article <UsOue.37224$b5.1563724 at news3.tin.it>,
 "Enrico" <lux at perpetua.org> wrote:

> "Joseph Garvin" <k04jg02 at kzoo.edu> ha scritto nel messaggio
> news:mailman.837.1119596150.10512.python-list at python.org...
> > --This code won't run because it's in a comment block
> > --[[
> > print(10)
> > --]]
> >
> > --This code will, because the first two dashes make the rest a comment,
> > breaking the block
> > ---[[
> > print(10)
> > --]]
> >
> > So you can change whether or not code is commented out just by adding a
> > dash. This is much nicer than in C or Python having to get rid of """ or
> > /* and */. Of course, the IDE can compensate. But it's still neat :)
> 
> python:
> 
> """
> print 10
> """
> 
> and
> 
> #"""
> print 10
> #"""


It seems to me that this trick works in Python,too.

"""
print 10
#"""

and

#"""
print 10
#"""


You only have to change the first triple quote.

-- 
Doug Schwarz
dmschwarz&urgrad,rochester,edu
Make obvious changes to get real email address.



More information about the Python-list mailing list