Re: [Tutor] Class Tips

2009-05-31 Thread Alan Gauld
"David" wrote OK, this is what I came up with, how else could I do it so as not to use sys.exit() ? You don;t need the exit(), The program will just drop off the end silently without it. Thre are several other redundant bits you could just miss out: class FertRate: def __init__(self,

Re: [Tutor] Class Tips

2009-05-31 Thread David
W W wrote: One thing that's probably not in the scope of the program but really usually a good idea is error checking. i.e. this line: rate = float(raw_input("Enter rate i.e. (0.5) : ")) could be converted to something like: try: rate = float(raw_input("Enter rate...")) except ValueErr

Re: [Tutor] Class Tips

2009-05-31 Thread David
ALAN GAULD wrote: but I get an error here; def main(): frate = FertRate(get_inputs()) File "./fert_class.py", line 15, in main frate = FertRate(get_inputs()) TypeError: __init__() takes exactly 5 arguments (2 given) Sorry my mistake. Because get_inputs() returns a tuple you h

Re: [Tutor] Class Tips

2009-05-30 Thread W W
On Sat, May 30, 2009 at 8:20 PM, David wrote: > > Alan Gauld wrote: >> >> "David" wrote >> >>> I took this program that determines a fertilizer application rate; >>> ... >>> And converted it to class/object to learn how they work. Just looking for some pointers, if I did it correctly etc. >>> >>>

Re: [Tutor] Class Tips

2009-05-30 Thread David
Alan Gauld wrote: "David" wrote I took this program that determines a fertilizer application rate; ... And converted it to class/object to learn how they work. Just looking for some pointers, if I did it correctly etc. For such a small program its hard to see what else you could have done.

Re: [Tutor] Class Tips

2009-05-30 Thread Alan Gauld
"David" wrote I took this program that determines a fertilizer application rate; ... And converted it to class/object to learn how they work. Just looking for some pointers, if I did it correctly etc. For such a small program its hard to see what else you could have done. Technically itys

[Tutor] Class Tips

2009-05-30 Thread David
I took this program that determines a fertilizer application rate; #!/usr/bin/python rate = float(raw_input("Enter rate i.e. (0.5) : ")) n = float(raw_input("Enter N from bag i.e. (.14) : ")) app = rate / n area = 43.560 acre = input("Enter total acre's to be treated: ") bag = input("Enter bag w