[Tutor] User selections question

William Perry wmperry@swbell.net
Thu, 05 Apr 2001 22:19:10 -0500


--=====_98652715029358=_
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable

Obligatory background "stuff ";

I'm still new at this programing hobby and all self-taught. I've gone thru=
 Alan's online tutorial, Teach Yourself Python in 24 hrs, most of Learning=
 Python and the Tutorial packaged with Python (and hung around this list=
 about 6 months). I wanted to try writing something from scratch to see if=
 any of it had sunk in.

It appears it did because what was to be a simple function has grown into 4=
 stand alone modules that properly combined will actually automate a very=
 boring task where I work. At least according to the 'alpha testers' at the=
 job who are clamoring for a finished product.

The problem;

I have a working function that takes user selections and selects among the=
 sub-modules returning values to send to the final data module but it feels=
 clumsy. Since this is still after all a learning project I'm looking for=
 how to find the answer rather than the answer it's self.

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D what I want to=
 do=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

1)user selects from a listing of available functions
2)the selected functions run and return a list of values
3)the combine function processes the list to a final value
4)print to screen/printer
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D

I'm hung up on step 1


This is what I came up with just playing with the idea. (yes I did do some=
 BASIC back in the late 70's )



def com_rate():
 l=3D[]
 tst=3D1
 y=3D99
 print;print"enter area # for area to rate \n 1-area 1 \n 2-area 2"
 print "enter y to begin"
 print;print
 while tst:
  
         area=3Dinput("enter ")
         if area =3D=3D 1:
      res=3Darea1()
      l.append(res)
         elif area =3D=3D 2:
      res=3Darea2()
      l.append(res)
         elif area =3D=3D 99:
      combn(l)
      break
         else:
      tst=3D0

def area1():
 out=3D11
 return out

def area2():
 out=3D5
 return out

def combn(l):
 print l
 tst=3D0
 return tst
 
com_rate()





************************************Something else i=
 tried**********************************

#! usr/bin/python

def com_test():
    l=3D[]
    print" Enter number of areas to be rated "
    arl=3Dinput("Enter ")
    print;print"enter area # for area to rate \n 1-area 1 \n 2-area 2"
    for ar in range (arl):
        ar=3Dinput("? ")
        l.append (ar) 
        
    print l

com_test()


    
    
    
(and like even less)


--=====_98652715029358=_
Content-Type: text/html; charset="us-ascii"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 5.50.4611.1300" name=GENERATOR></HEAD>
<BODY style="FONT-FAMILY: Arial" text=#000000 bgColor=#ffffff>
<DIV><FONT size=2>Obligatory background "stuff ";</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>I'm still new at this programing hobby and all self-taught. 
I've gone thru Alan's online tutorial, Teach Yourself Python in 24 hrs, most of 
Learning Python and the Tutorial packaged with Python (and hung around this list 
about 6 months). I wanted to try writing something from scratch to see if any of 
it had sunk in.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>It appears it did because what was to be a simple function has 
grown into 4 stand alone modules that properly combined will actually automate a 
very boring task where I work. At least according to the 'alpha testers' at the 
job who are clamoring for a finished product.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>The problem;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>I have a working function that takes user selections and 
selects among the sub-modules returning values to send to the final data module 
but it feels clumsy. Since this is still after all a learning project I'm 
looking for how to find the answer rather than the answer it's 
self.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>=================== what I want to do============</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>1)user selects from a listing of available functions<BR>2)the 
selected functions run and return a list of values<BR>3)the combine function 
processes the list to a final value<BR>4)print to 
screen/printer<BR>=======================================================</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>I'm hung up on step 1</FONT></DIV>
<DIV>&nbsp;</DIV><FONT size=2>
<DIV><BR>This is what I came up with just playing with the idea. (yes I did do 
some BASIC back in the late 70's )</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>def 
com_rate():<BR>&nbsp;l=[]<BR>&nbsp;tst=1<BR>&nbsp;y=99<BR>&nbsp;print;print"enter 
area # for area to rate \n 1-area 1 \n 2-area 2"<BR>&nbsp;print "enter y to 
begin"<BR>&nbsp;print;print<BR>&nbsp;while 
tst:<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
area=input("enter ")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if area 
== 1:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
res=area1()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
l.append(res)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elif area == 
2:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
res=area2()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
l.append(res)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elif area == 
99:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; combn(l)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
break<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
else:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tst=0</DIV>
<DIV>&nbsp;</DIV>
<DIV>def area1():<BR>&nbsp;out=11<BR>&nbsp;return out</DIV>
<DIV>&nbsp;</DIV>
<DIV>def area2():<BR>&nbsp;out=5<BR>&nbsp;return out</DIV>
<DIV>&nbsp;</DIV>
<DIV>def combn(l):<BR>&nbsp;print l<BR>&nbsp;tst=0<BR>&nbsp;return 
tst<BR>&nbsp;<BR>com_rate()</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>************************************Something else i 
tried**********************************</DIV>
<DIV>&nbsp;</DIV>
<DIV>#! usr/bin/python</DIV>
<DIV>&nbsp;</DIV>
<DIV>def com_test():<BR>&nbsp;&nbsp;&nbsp; l=[]<BR>&nbsp;&nbsp;&nbsp; print" 
Enter number of areas to be rated "<BR>&nbsp;&nbsp;&nbsp; arl=input("Enter 
")<BR>&nbsp;&nbsp;&nbsp; print;print"enter area # for area to rate \n 1-area 1 
\n 2-area 2"<BR>&nbsp;&nbsp;&nbsp; for ar in range 
(arl):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ar=input("? 
")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; l.append (ar) 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; print 
l</DIV>
<DIV>&nbsp;</DIV>
<DIV>com_test()</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; 
<BR>(and like even less)</FONT></DIV></BODY></HTML>


--=====_98652715029358=_--