2012/1/1 Nick Coghlan <ncogh...@gmail.com>: > I've been having an occasional argument with Benjamin regarding braces > in 4-line if statements:
Python's C code has been dropping braces long before I ever arrived. See this beautiful example in dictobject.c, for example: if (numfree < PyDict_MAXFREELIST && Py_TYPE(mp) == &PyDict_Type) free_list[numfree++] = mp; else Py_TYPE(mp)->tp_free((PyObject *)mp); There's even things like this: if (ep->me_key == dummy) freeslot = ep; else { if (ep->me_hash == hash && unicode_eq(ep->me_key, key)) return ep; freeslot = NULL; } where I would normally put braces on both statements. I think claims of its maintainability are exaggerated. (If someone could cite an example of a bug caused by braces, I'd be interested to see it.) If I start editing one of the bodies, emacs will dedent, so that I know I'm back to the containing block. By virtue of being 5 lines long, it's a very easy case to see and fix as you edit it. I think it's fine Nick raised this. PEP 7 is not very explicit about braces at all. -- Regards, Benjamin _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com