Seek Python Warning For A Multiply Defined Function
Q: is there a way to get Python to give me a warning when there is more than one definition of the same function, conflicting, etc. (I just wasted a bit of time making edits to two
Solution 1:
No, there's no way to get Python to behave this way natively. A function definition is essentially an assignment to a name, and names in Python can be reassigned at any time. Functions are not treated in any special way compared to integers, strings, etc.
Solution 2:
You can decorate all you functions and create a database of symbols and warn on redefinitions.
Solution 3:
there's nothing built into the language, but you can use a code-checking tool like pylint (and I believe there are other tools), which will find these kinds of things and warn you about them.
Post a Comment for "Seek Python Warning For A Multiply Defined Function"