Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Strict mode?

Reply
Thread Tools

Strict mode?

 
 
Jack
Guest
Posts: n/a
 
      12-18-2007
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?


 
Reply With Quote
 
 
 
 
John Machin
Guest
Posts: n/a
 
      12-18-2007
On Dec 19, 9:03 am, "Jack" <(E-Mail Removed)> 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.
 
Reply With Quote
 
 
 
 
Larry Bates
Guest
Posts: n/a
 
      12-18-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
 
Reply With Quote
 
Noah Dain
Guest
Posts: n/a
 
      12-19-2007
On Dec 18, 2007 5:03 PM, Jack <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Strict priority for a system? Grue Cisco 4 05-05-2004 02:48 AM
What am I doing wrong when using "use strict" ? ed Perl 1 01-05-2004 01:22 PM
What does "fixup ftp STRICT" means in practice ? jarcar Cisco 1 12-05-2003 03:47 PM
Re: How to turn Strict "off"? Andrew Crawford ASP .Net 1 07-13-2003 10:26 PM
How to turn Strict "off"? Andy Crawford ASP .Net 1 07-11-2003 01:50 PM



Advertisments