proper use of braces in Python (was: Prothon Prototypes vs Python Classes)

Michael mogmios at mlug.missouri.edu
Tue Mar 30 19:12:45 EST 2004


>>Right.  Then we can have "does the brace go on the same line or the
>>next line" wars.
>>    
>>
>
>    int main (void)
>    {
>        if (true)
>        {
>        }
>
>        return 0;
>    }
>
>There is no other way.
>  
>
No way, that wastes an entire line of code with a single brace!

int main ( void ) {
    if ( true ) {
        return 1;
    }
    return 0;
}

This is clearly better. Compact yet easy to read. I try formatting my 
Python code exactly like this and it always complains about my braces.. 
clearly wrong.




More information about the Python-list mailing list