Strict mode?

Discussion in 'Python' started by Jack, Dec 18, 2007.

  1. Jack

    Jack Guest

    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?
    Jack, Dec 18, 2007
    #1
    1. Advertising

  2. Jack

    John Machin Guest

    On Dec 19, 9:03 am, "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.


    This specific problem can be addressed at least partially by setting
    reasonable defaults for new arguments. This is a necessary technique
    when the publisher of a language or a module/package wants to extend
    the functionality of a function or method without introducing a new
    name for the function/method.

    The general problem is usually addressed in dynamic languages by
    running a test suite.
    John Machin, Dec 18, 2007
    #2
    1. Advertising

  3. Jack

    Larry Bates Guest

    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
    Larry Bates, Dec 18, 2007
    #3
  4. Jack

    Noah Dain Guest

    On Dec 18, 2007 5:03 PM, 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?
    >
    >
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >


    Description: A refactoring tool for python
    A framework and refactoring tool for Python. IDE Plugins are included for
    Pymacs, IDLE and Vim. Using Bicycle Repair Man you can rename classes, methods
    and variables, and all users of them are found and adjusted appropriately.
    .
    Homepage: http://bicyclerepair.sourceforge.net/


    --
    Noah Dain
    "The beatings will continue, until morale improves" - the Management
    Noah Dain, Dec 19, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John J Lee
    Replies:
    3
    Views:
    458
    bruno at modulix
    Dec 1, 2005
  2. Edward Loper
    Replies:
    0
    Views:
    448
    Edward Loper
    Aug 7, 2007
  3. John J Lee
    Replies:
    0
    Views:
    505
    John J Lee
    Aug 7, 2007
  4. Edward Loper

    mmm-mode, python-mode and doctest-mode?

    Edward Loper, Aug 9, 2007, in forum: Python
    Replies:
    0
    Views:
    417
    Edward Loper
    Aug 9, 2007
  5. Neal Becker
    Replies:
    0
    Views:
    370
    Neal Becker
    Aug 9, 2007
Loading...

Share This Page