Re: avoid the redefinition of a function

2012-09-13 Thread Alister
On Thu, 13 Sep 2012 10:23:22 +0200, Peter Otten wrote: > MRAB wrote: > >> On 12/09/2012 19:04, Alister wrote: >>> On Wed, 12 Sep 2012 18:56:46 +0200, Jabba Laci wrote: >>> > For example: > > def install_java(): >pass > > def install_tomcat(): >pass Th

Re: avoid the redefinition of a function

2012-09-13 Thread Peter Otten
MRAB wrote: > On 12/09/2012 19:04, Alister wrote: >> On Wed, 12 Sep 2012 18:56:46 +0200, Jabba Laci wrote: >> For example: def install_java(): pass def install_tomcat(): pass >>> >>> Thanks for the answers. I decided to use numbers in the name of the >>> fu

Re: avoid the redefinition of a function

2012-09-12 Thread D'Arcy Cain
On Wed, 12 Sep 2012 17:45:52 -0500 Tim Chase wrote: > On 09/12/12 16:47, D'Arcy Cain wrote: > > And run all of your tests every day. You will sleep better at night. > > Though I usually try to do test-driven development, I confess a > fondness for Titus Brown's "Stupidity driven testing"[1] :-)

Re: avoid the redefinition of a function

2012-09-12 Thread Dave Angel
On 09/12/2012 12:56 PM, Jabba Laci wrote: > Thanks for the answers. I decided to use numbers in the name of the > functions to facilitate function calls. Now if you have this menu > option for instance: > > (5) install mc > > You can type just "5" as user input and step_5() is called > automaticall

Re: avoid the redefinition of a function

2012-09-12 Thread Tim Chase
On 09/12/12 16:47, D'Arcy Cain wrote: > On Wed, 12 Sep 2012 16:37:11 -0400 > Terry Reedy wrote: >> 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.) > >

Re: avoid the redefinition of a function

2012-09-12 Thread D'Arcy Cain
On Wed, 12 Sep 2012 18:04:51 GMT Alister wrote: > No No NO! > you cant just pass user input to system calls without validating it first > (google sql injection for examples of the damage unsanitised input can > cause, it is not just as SQL problem) http://xkcd.com/327/ -- D'Arcy J.M. Cain

Re: avoid the redefinition of a function

2012-09-12 Thread D'Arcy Cain
On Wed, 12 Sep 2012 16:37:11 -0400 Terry Reedy wrote: > 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.) 1. Write the test 2. Run the test - make sure it

Re: avoid the redefinition of a function

2012-09-12 Thread D'Arcy Cain
On Wed, 12 Sep 2012 18:56:46 +0200 Jabba Laci wrote: > (5) install mc > > You can type just "5" as user input and step_5() is called > automatically. If I use descriptive names like install_java() then > selecting a menu point would be more difficult. And I don't want users > to type "java", I wa

Re: avoid the redefinition of a function

2012-09-12 Thread Terry Reedy
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.

Re: avoid the redefinition of a function

2012-09-12 Thread MRAB
On 12/09/2012 19:04, Alister wrote: On Wed, 12 Sep 2012 18:56:46 +0200, Jabba Laci wrote: For example: def install_java(): pass def install_tomcat(): pass Thanks for the answers. I decided to use numbers in the name of the functions to facilitate function calls. Now if you have this m

Re: avoid the redefinition of a function

2012-09-12 Thread Alister
On Wed, 12 Sep 2012 18:56:46 +0200, Jabba Laci wrote: >> For example: >> >> def install_java(): >>pass >> >> def install_tomcat(): >>pass > > Thanks for the answers. I decided to use numbers in the name of the > functions to facilitate function calls. Now if you have this menu option > fo

Re: avoid the redefinition of a function

2012-09-12 Thread Tim Chase
On 09/12/12 11:56, Jabba Laci wrote: >> For example: >> >> def install_java(): >>pass >> >> def install_tomcat(): >>pass > > Thanks for the answers. I decided to use numbers in the name of the > functions to facilitate function calls. Now if you have this menu > option for instance: > > (

Re: avoid the redefinition of a function

2012-09-12 Thread Jabba Laci
> For example: > > def install_java(): >pass > > def install_tomcat(): >pass Thanks for the answers. I decided to use numbers in the name of the functions to facilitate function calls. Now if you have this menu option for instance: (5) install mc You can type just "5" as user input and s

Re: avoid the redefinition of a function

2012-09-12 Thread Michael Torrie
On 09/12/2012 06:56 AM, Jabba Laci wrote: > I have an installer script that contains lots of little functions. It > has an interactive menu and the corresponding function is called. Over > time it grew long and when I want to add a new function, I should give > a unique name to that function. Howev

Re: avoid the redefinition of a function

2012-09-12 Thread Alister
On Wed, 12 Sep 2012 06:15:21 -0700, Ramchandra Apte wrote: > On Wednesday, 12 September 2012 18:26:36 UTC+5:30, Jabba Laci wrote: >> Hi, >> >> >> >> I have an installer script that contains lots of little functions. It >> >> has an interactive menu and the corresponding function is called. Ov

Re: avoid the redefinition of a function

2012-09-12 Thread D'Arcy Cain
On Wed, 12 Sep 2012 14:56:12 +0200 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

Re: avoid the redefinition of a function

2012-09-12 Thread Ken Seehart
Use lambda expressions to define some constraints: gt = lambda x: lambda y: x>y eq = lambda x: lambda y: x==y constraints = [gt(2), eq(1)] data = [3,1] for i,c in enumerate(constraints): print c(data[i]) On 9/12/2012 5:56 AM, Jabba Laci wrote: > Hi, > > I have an installer script t

Re: avoid the redefinition of a function

2012-09-12 Thread Ramchandra Apte
On Wednesday, 12 September 2012 18:26:36 UTC+5:30, Jabba Laci wrote: > Hi, > > > > I have an installer script that contains lots of little functions. It > > has an interactive menu and the corresponding function is called. Over > > time it grew long and when I want to add a new function, I sh

avoid the redefinition of a function

2012-09-12 Thread Jabba Laci
Hi, I have an installer script that contains lots of little functions. It has an interactive menu and the corresponding function is called. Over time it grew long and when I want to add a new function, I should give a unique name to that function. However, Python allows the redefinition of functio