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

Paul McGuire ptmcg at austin.rr._bogus_.com
Wed Mar 31 09:11:34 EST 2004


"Michael" <mogmios at mlug.missouri.edu> wrote in message
news:mailman.148.1080691972.20120.python-list at python.org...
>
> >>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.
>
http://c2.com/cgi/wiki/wiki?WhereDoTheBracesGo

Not having to deal with this #$*^!!@ is just about my favorite feature of
Python!  (Although I'm not excited about getting into a thread on an issue
that is so flame-prone.  Honestly, though. "There is no other way."?  "This
is clearly better."?  I really interpret your stance as "This is the way I'm
used to."  What's annoying is the added "... and therefore superior."
implication.  The visual cues provided by brace placement are extremely
subjective, and what is "clearly better" to one is confusing to another.)

Is it so difficult to accept that this is a personal style/preference issue?
I agree that having a consistent form across an entire project makes things
simpler overall, it's not worth the aggravation of coercing a style on those
who vigorously and adamantly prefer their own.  Furthermore,...

Oh wait, Python doesn't *have* braces!  Whew!  (What a funny subject for a
thread on c.l.py - April Fool's Day is come a bit early?)

-- Paul







More information about the Python-list mailing list