New to Python - block grouping (spaces)

Antoon Pardon antoon.pardon at rece.vub.ac.be
Thu Apr 16 08:48:32 EDT 2015


On 04/16/2015 06:07 AM, Blake McBride wrote:
> Greetings,
>
> I am new to Python.  I am sorry for beating what is probably a dead horse but I checked the net and couldn't find the answer to my question.
>
> I like a lot of what I've seen in Python, however, after 35 years and probably a dozen languages under my belt, I very strongly disagree with the notion of using white space to delimit blocks.  Not wanting to beat what I believe is probably a dead horse, I have one question.  
>
> Is there a utility that will allow me to write Python-like code that includes some block delimiter that I can see, that converts the code into runnable Python code?  If so, where can I find it?
>
> Thanks!
>
> Blake McBride

If you really want this, and don't like using comments to achieve this,
you can do the folling.

endfor = endif = enddef = endwhile = None

def poweri(a, i):
    if i < 0:
        i = -i
        fac = 1.0 / a
    else:
        fac = a
    endif
    total = 1
    while i:
        if i % 2:
            total *= fac
        endif
        fac *= fac
        i /= 2
    endwhile
    return total
enddef
        




More information about the Python-list mailing list