On 16/10/2020 07:55, Steven D'Aprano wrote:
Hmmm, well, I won't categorically say you *must* use a function, but I
will say that using a function is probably the best solution.
If you nest your function inside the major function, you don't even need
to pass arguments:
def function(a, b, c, d, e):
# More local variables:
f, g, h = 1, 2, 3
def inner():
# all locals a...h are visible in here
return result
thing = inner()
so you may be able to move your processing to an inner function, without
needing to explicit pass any arguments to it, and make use of return,
rather than adding a loop so you can use break.
Thank you - good suggestion. (Except for apps which are
performance-critical where I would expect defining a function each time
the major function is called to have significant overhead. My apps
usually aren't.)
Rob Cliffe
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/PCAFOFJSLVVJKH3FLDODNTU3NF6CCB2L/
Code of Conduct: http://python.org/psf/codeofconduct/