Re: [Tutor] Sys.argv read parameters

2013-04-17 Thread Dave Angel
On 04/17/2013 08:12 PM, Alan Gauld wrote: On 17/04/13 20:27, Danilo Chilene wrote: import sys a = 'This is A' b = 'This is B' c = 'This is C' for i in sys.argv[1]: if sys.argv[1] == 'a': print a if sys.argv[1] == 'b': print b if sys.argv[1] == 'c': pr

Re: [Tutor] Sys.argv read parameters

2013-04-17 Thread Alan Gauld
On 17/04/13 20:27, Danilo Chilene wrote: import sys a = 'This is A' b = 'This is B' c = 'This is C' for i in sys.argv[1]: if sys.argv[1] == 'a': print a if sys.argv[1] == 'b': print b if sys.argv[1] == 'c': print c I run python file.py a and returns t

Re: [Tutor] Sys.argv read parameters

2013-04-17 Thread Mark Lawrence
On 17/04/2013 20:27, Danilo Chilene wrote: Dear Python Tutor, I have the code below(file.py): import sys a = 'This is A' b = 'This is B' c = 'This is C' for i in sys.argv[1]: if sys.argv[1] == 'a': print a if sys.argv[1] == 'b': print b if sys.argv[1] == 'c':

Re: [Tutor] Sys.argv read parameters

2013-04-17 Thread Dave Angel
On 04/17/2013 05:15 PM, Danny Yoo wrote: Yup! Sorry about my tone for its stridency. But I just got concerned that the original poster seemed content about turning the chain of if statements into a table definition. To my mind, they're very closely related, data and control. I'm trying to pus

Re: [Tutor] Sys.argv read parameters

2013-04-17 Thread Danny Yoo
Yup! Sorry about my tone for its stridency. But I just got concerned that the original poster seemed content about turning the chain of if statements into a table definition. To my mind, they're very closely related, data and control. I'm trying to push the OP to realizing that if they are doin

Re: [Tutor] Sys.argv read parameters

2013-04-17 Thread Dave Angel
On 04/17/2013 04:49 PM, Danny Yoo wrote: Wait. If the solution that we're stopping at to use a hashtable here, that's not quite right. Nothing wrong with a dict, if a proper specification of the problem were available. Notice that in my solution, the messages were not all trivially related

Re: [Tutor] Sys.argv read parameters

2013-04-17 Thread Danny Yoo
Wait. If the solution that we're stopping at to use a hashtable here, that's not quite right. A good solution to this should be _much_ shorter, on the order of a one-liner. Hashtables are great, but they're not the answer to everything. If we're doing something like: a -> "This is A" b

Re: [Tutor] Sys.argv read parameters

2013-04-17 Thread Danilo Chilene
Hello Dave, 1) I'm using Python 2.7 2) The program wasn't suppose to really work, was just a example. 3) You assumed correct. That's was what I looking for, worked like charm. Thanks! On Wed, Apr 17, 2013 at 5:18 PM, Dave Angel wrote: > On 04/17/2013 03:27 PM, Danilo Chilene wrote: > >> Dear

Re: [Tutor] Sys.argv read parameters

2013-04-17 Thread Marc Tompkins
On Wed, Apr 17, 2013 at 1:03 PM, Danny Yoo wrote: > ## > ## double: string -> string > def double(x): > return x + x > > > ## For example, a blast from the past: > print "The Noid says: " + double("pizza") > ## > I'm sorry, but this is a bug.

Re: [Tutor] Sys.argv read parameters

2013-04-17 Thread Dave Angel
On 04/17/2013 03:27 PM, Danilo Chilene wrote: Dear Python Tutor, I have the code below(file.py): import sys a = 'This is A' b = 'This is B' c = 'This is C' for i in sys.argv[1]: if sys.argv[1] == 'a': print a if sys.argv[1] == 'b': print b if sys.argv[1] == 'c

Re: [Tutor] Sys.argv read parameters

2013-04-17 Thread Danny Yoo
What's the part that's "changing"? What's the part that stays the same? I would recommend thinking of this in terms of a function. Can you write a function that consumes a letter l and returns the string "This is ..." where "..." is the uppercased l? As an example of a simple function on string

[Tutor] Sys.argv read parameters

2013-04-17 Thread Danilo Chilene
Dear Python Tutor, I have the code below(file.py): import sys a = 'This is A' b = 'This is B' c = 'This is C' for i in sys.argv[1]: if sys.argv[1] == 'a': print a if sys.argv[1] == 'b': print b if sys.argv[1] == 'c': print c I run python file.py a and return