avoid the redefinition of a function
Terry Reedy
tjreedy at udel.edu
Wed Sep 12 16:37:11 EDT 2012
On 9/12/2012 8:56 AM, Jabba Laci wrote:
> This will call the 2nd function. Now my functions are called step_ID
> (like step_27(), step_28(), etc.). How to avoid the danger of
> redefinition? Now, when I write a new function, I search for its name
> to see if it's unique but there must be a better way.
Before starting to write the new function, write a test and see if it
fails with a "NameError new_name not found". The test failure also
assures one that the test is being run. (I don't always test first, but
I once discovered a test not being run when I modified it in a way that
should have made it fail, but it didn't.)
--
Terry Jan Reedy
More information about the Python-list
mailing list