My (slightly goofy) coding standard
Hi all -- I have just completed one pass over the Distutils source to enforce one minor coding convention: whitespace next to the open parentheses when calling a function (or other callable). Anyone hacking on the Distutils needs to know about this convention, which is slightly odd but quite defensible (IMHO): * when *defining* a callable, use a space: def foo (): ... def foo (arg1, arg2, ...): ... class SubThing (Thing): ... * corollary: for long functions that need a "# end"-style line, it looks like this: def foo (): # > 40 lines of code (say) # foo () because the "# foo ()" line is part of the definition * when *using* a callable, no space: foo() thing.foo() foo(2, "hello") this.that.get_something().foo.name_of_long_method( arg1, arg2, arg3, ...) Rationale: this makes it trivial (grep-wise) to distinguish between *definition* and *use*. I *know* what Guido's coding standard says, but the problem with "def foo()" is that you can't search for use only without a negative lookbehind to exclude "def" lines... and my "grep" doesn't have negative lookbehind. Anyways, that's the Distutils convention as of tonight. Please respect it when hacking on the code! (And please fix deviance if you submit patches: I've only fixed up distutils/*.py, excluding *ccompiler.py because of a pending patch. distutils/command/*.py is still to go; I can only do so much brain-dead search 'n replace work at once.) Greg -- Greg Ward gward@python.net http://starship.python.net/~gward/
"GW" == Greg Ward <gward@python.net> writes:
GW> Hi all -- I have just completed one pass over the Distutils GW> source to enforce one minor coding convention: whitespace next GW> to the open parentheses when calling a function (or other GW> callable). Anyone hacking on the Distutils needs to know about GW> this convention, which is slightly odd [...] It is really unfortunate that you have chosen to go this route. We are trying to make all the Python code in the standard library follow Guido's coding style. http://www.python.org/doc/essays/styleguide.html We will slow fix code in the library to follow these conventions, which will make distutils the only part of the core that doesn't follow them. Jeremy
[Jeremy responds to my coding convention]
It is really unfortunate that you have chosen to go this route. We are trying to make all the Python code in the standard library follow Guido's coding style.
Two points in my defence: * the search-and-replace work I did the other night brings the Distutils code *closer* to Guido's style guide, not farther away. I changed a lot of "foo (...)" calls to "foo(...)", because I have recently seen the light over that particular use of whitespace. (Also, almost all docstrings are now consistent with the Docstring Gospel According to Barry.) * I didn't know there was an ongoing push to standardize the standard library. When I'm done fixing up the Distutils code, if you really want to make it conform, that can be done trivially: perl -pi~ -e 's/^( *)(def|class) *\(/$1$2\(/' *.py command/*.py (Oops, that doesn't catch my end-of-function "# foo ()" convention.) I still like my way better, but an imperfect standard is better than no standard at all. Greg -- Greg Ward gward@python.net http://starship.python.net/~gward/
participants (2)
-
Greg Ward
-
Jeremy Hylton