SPUG: double curlies [was RE: One Python users' view of Perl]

Bill Campbell bill at celestial.com
Thu Jun 14 22:48:18 PDT 2007


On Thu, Jun 14, 2007, Michael R. Wolf wrote:
>> if test -d /directory; then #{{
>>     # do something
>> else #}{
>>     # do something else
>> fi #}}
>
>Curlies++
>
>Clever use of double curlies!!  It makes great sense from the end of an else
>clause to go back to the beginning of the block or the controlling if.  Neat
>idea.

Where it really is effective is when dealing with large numbers
of elifs or try/except with many different exceptions.

In python:

try: #{{
    commands here
#}
except someexception: #{
    commands
#}
except anotherexceptin: #{
    ...
#}}

I have code that handles very low-level keyboard input which
traps exceptions for various function keys (pretty much any
non-ascii input is an exception).

Bill
--
INTERNET:   bill at Celestial.COM  Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676

``Whenever you find yourself on the side of the majority it is time to
pause and reflect.''
               -- Mark Twain


More information about the spug-list mailing list