Strict mode?
Larry Bates
larry.bates at websafe.com
Tue Dec 18 18:29:26 EST 2007
Jack wrote:
> While enjoying the dynamic feature of Python I find it difficult to refactor
> code without breaking it. For example, if I modify a function to take more
> arguments, or arguments of different types, I'll need to manually find out
> all places where the function is called and make sure I modify them all,
> unlike in C/Java, where the compiler will do the work of checking function
> signatures, etc. I suppose there isn't a strict mode in Python. It would be
> helpful though, when I don't need things to be so dynamic, and this is often
> the case, when it comes to function arguments and return values, for
> example. Even a module level or function level flag would be very helpful to
> find broken code. Or, are there any third party tools that do this?
>
>
> if I modify a function to take more
> arguments, or arguments of different types, I'll need to manually find out
> all places where the function is called and make sure I modify them all
This is not necessarily true. I add keyword arguments to functions quite
commonly and they don't affect any of the previously defined calls. If I do, a
good editor with search/replace seems to do the trick. I find it quite uncommon
to change the "types" of arguments, but when I do, I can use duck typing to work
around that as well. Hang in there, you will get it.
-Larry
More information about the Python-list
mailing list