[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> </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> </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> </DIV>
<DIV><FONT size=2>The problem;</FONT></DIV>
<DIV> </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> </DIV>
<DIV><FONT size=2>=================== what I want to do============</FONT></DIV>
<DIV> </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> </DIV>
<DIV><FONT size=2>I'm hung up on step 1</FONT></DIV>
<DIV> </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> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>def
com_rate():<BR> l=[]<BR> tst=1<BR> y=99<BR> print;print"enter
area # for area to rate \n 1-area 1 \n 2-area 2"<BR> print "enter y to
begin"<BR> print;print<BR> while
tst:<BR> <BR>
area=input("enter ")<BR> if area
== 1:<BR>
res=area1()<BR>
l.append(res)<BR> elif area ==
2:<BR>
res=area2()<BR>
l.append(res)<BR> elif area ==
99:<BR> combn(l)<BR>
break<BR>
else:<BR> tst=0</DIV>
<DIV> </DIV>
<DIV>def area1():<BR> out=11<BR> return out</DIV>
<DIV> </DIV>
<DIV>def area2():<BR> out=5<BR> return out</DIV>
<DIV> </DIV>
<DIV>def combn(l):<BR> print l<BR> tst=0<BR> return
tst<BR> <BR>com_rate()</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>************************************Something else i
tried**********************************</DIV>
<DIV> </DIV>
<DIV>#! usr/bin/python</DIV>
<DIV> </DIV>
<DIV>def com_test():<BR> l=[]<BR> print"
Enter number of areas to be rated "<BR> arl=input("Enter
")<BR> print;print"enter area # for area to rate \n 1-area 1
\n 2-area 2"<BR> for ar in range
(arl):<BR> ar=input("?
")<BR> l.append (ar)
<BR> <BR> print
l</DIV>
<DIV> </DIV>
<DIV>com_test()</DIV>
<DIV> </DIV>
<DIV><BR> <BR> <BR>
<BR>(and like even less)</FONT></DIV></BODY></HTML>
--=====_98652715029358=_--