Why not allow empty code blocks?
Chris Angelico
rosuav at gmail.com
Sun Jul 24 07:27:13 EDT 2016
On Sun, Jul 24, 2016 at 8:45 PM, BartC <bc at freeuk.com> wrote:
> 'end' to terminate a block can be emulated of course:
>
> end=0
>
> def fn(a):
> if a<=1:
> return 1
> else:
> return fn(a-1)
> end
> end
>
> And in this example it wouldn't impact on performance as it is not
> evaluated.
Actually, they would be (you'll have a LOAD_GLOBAL followed by
POP_TOP). Much better to use Python's inbuilt hash-braces support,
available via a hash-future directive.
#from __future__ import braces
def fn(a): #{
if a <= 1: #{
return 1
#}
else: #{
return fn(a-1)
#}
#}
ChrisA
More information about the Python-list
mailing list