is there any principle when writing python function

Chris Angelico rosuav at
Fri Aug 26 12:10:34 EDT 2011

On Sat, Aug 27, 2011 at 1:48 AM, Tobiah <tobiah at> wrote:
> While I understand and agree with that basic tenet, I think
> that the capitalized 'ONLY' is too strong.  I do split out
> code into function for readability, even when the function
> will only be called from the place from which I split it out.

This can be good and can be bad. It's good when it aids readability;
it's bad when you need to pass practically the entire locals() as
function arguments and/or return values. I would split the function
only when both halves (caller and callee) can be given short and
useful names - if you can't explain what a block of code does in a few
words, it's probably a poor choice for splitting out into a function.


More information about the Python-list mailing list