Open GoogleCodeExporter opened 9 years ago
Arguments for exposing public methods as Python functions:
* Allows functional programming (compositions, etc)
* User doesn't need to call sympify() on input
* Functions are easier to find in documentation
* We can change the method API without affecting the public user interface
One question is: should all functions, including "expression operators" like
expand
(as opposed to mathematical operators like diff) be named in CamelCase as well
(e.g.
Expand)? I think they probably should; naming all public functions the same way
(optionally implementing them as Basic subclasses as well) would be most
consistent.
Original comment by fredrik....@gmail.com
on 5 Nov 2007 at 5:15
I have no objections on exposing public methods as functions.
However, could you explain why do you prefer CamelCase for
functions while Python style guide recommends camelcase?
Note that I am ok with either way (as long as it is done consistently)
but some like to follow Python guide lines and so I would
choose camelcase as a first choice.
Original comment by pearu.peterson
on 5 Nov 2007 at 7:34
Mainly for consistency. I don't think it's a particularly important issue.
Original comment by fredrik....@gmail.com
on 5 Nov 2007 at 7:47
I have no objections on these, I think it doesn't matter that much, as long as
it is
simple and follows Python conventions when possible.
It's true that it will be more work when integrating these changes in SymPy, but
that's the purpose of sympycore to create the best interface, without fearing of
breaking things. So let's do it.
Original comment by ondrej.c...@gmail.com
on 5 Nov 2007 at 8:28
http://www.python.org/doc/essays/styleguide.html says:
"A style guide is about consistency. Consistency with this style guide is
important.
Consistency within a project is more important. Consistency within one module or
function is most important."
In fact, it also says:
"Plain functions exported by a module can either use the CapWords style or
lowercase
(or lower_case_with_underscores). I have no strong preference, but believe that
the
CapWords style is used for functions that provide major functionality (e.g.
nstools.WorldOpen()), while lowercase is used more for "utility" functions (e.g.
pathhack.kos_root())."
There, Guido said it ;-)
However, he appears to have changed his mind more recently. The revised style
guide
at http://www.python.org/dev/peps/pep-0008/ says:
Function names should be lowercase, with words separated by underscores
as necessary to improve readability.
mixedCase is allowed only in contexts where that's already the
prevailing style (e.g. threading.py), to retain backwards compatibility.
Nothing about uppercase. Of course; that PEP is intended for the Python standard
library. While it's a good idea to follow it generally, there's always room for
making reasonable exceptions.
We have some good reasons for using uppercase:
* Avoid name clashes with builtins (e.g. abs/Abs, max/Max)
* Mathematica is a good precedent
Original comment by fredrik....@gmail.com
on 5 Nov 2007 at 8:57
Well done research. :) My own taste is also for lower case functions, but I
don't
have a strong opinion on this.
Original comment by ondrej.c...@gmail.com
on 5 Nov 2007 at 9:05
Original issue reported on code.google.com by
pearu.peterson
on 21 Oct 2007 at 10:00