"Richard D. Moores" <rdmoo...@gmail.com> wrote
to be put in a function. For convenience sake, I've put this new
function inside the one that calls it.

Question 1: Is this bad practice? It works fine that way, but..

No, but there are some issues to consider.
Denis has addressed some but one other is...

Reuse: by hiding the function inside the outer one it means it can only ever be used inside that function. It may be better to have it as a module level function - even if you use the _prefix to limit its use outside the module.

Question 2: If the answer to Q1 is no, is there a standard place to
put a function inside of another function? Is it standard to have it
the first line of the function? I've put mine at the point where it
would be called, mainly as a reminder to myself.

Top of the function is best because as Denis says it only gets defined once per function call. If you are really paranoid and the function only gets used in exceptional cases then you could define it at the point of use but in that case you probably don't need a function at all!

HTH,


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to