alternatives to making blocks like { } or other ??

Christopher Koppler klapotec at chello.at
Tue May 18 17:31:10 EDT 2004


On Tue, 18 May 2004 21:27:17 +0200, CYBER <usenet at zly_adres.com>
wrote:

>Hello
>
>Is there any other way under python to create blocks ??
>
>instead of
>
>def sth(x):
>	return x
>
>
>
>could i use something else like
>
>def sth(x):
>{
>	return x
>}
>
>
>???


Of course there is another way!

Just use # in front of your favourite block separator.

I'm too lazy now to search the archives on who first suggested this,
but it works:

def something(x):
#{
    return x
#}

However, as with any and all block separators, this can lead to holy
wars - is the above the 'one true way', or is it one of the following?
All are valid Python...

def something_else(x):
    #{
    return x
    #}

def something_or_other(x):
    #{
        return x
    #}

def something_completely_different(x): #(
    return x
#}





--
Christopher



More information about the Python-list mailing list