[Tutor] two input acceptions

adam urbas adamurbas at hotmail.com
Wed May 23 18:26:23 CEST 2007

Sorry, Hotmail doesn't have a turn of HTML feature or if it does, I couldn't find it.  I think I'm just going to take your word for it that raw_input is better because I find the entire concept quite confusing.  I tried typing in your example in IDLE and it didn't do anything, except:>>>>>>And then it told me that it didn't know what the >>("LOL") was.  It really disliked the >> bit.  I understand the concept though, I think.  I have been using the raw_input though.  If I change it from var=raw_input()>>("LOL")to var=raw_input("LOL")then it displays>>>LOL>>>Not sure what that means, but yeah.  Well thanks anyway.Adam> Date: Sat, 19 May 2007 01:47:51 +0100> From: finalyugi at sapo.pt> To: adamurbas at hotmail.com; tutor at python.org> Subject: Re: [Tutor] two input acceptions> > adam urbas escreveu:> > Thanks for the help.  I've made quite some progress since I first posted this email.  I have a question though, what did you mean when you were talking about the raw_input( )?  How can the regular input( ) be used evilly?  If you could explain in depth, I would be very grateful.  I have a new question related to my program area.py., I guess it's the same one as before.  When I run the program and input the rectangle option, it asks me for a radius, unless I input 1, instead of rectangle.  How do I program it to accept both 1 and rectangle?> Date: Sat, 12 May 2007 18:55:20 +0100> From: finalyugi at sapo.pt> To: adamurbas at hotmail.com> CC: tutor at python.org> Subject: Re: [Tutor] (no subject)> > adam urbas escreveu:> > Hi,I just started python today and I would like a few pointers, if you don't mind.  I tried using a tutorial, but was only able to get the correct results for the most basic problems.  # Area calculation programprint “Welcome to the Area calculation program”print “––> –––––––––––”print# Print out the menu:print “Please select a shape:”print “1  Rectangle”print “2  Circle”# Get the user’s choice:shape = input(“> “)# Calculate the area:if shape == 1:    height = input(“Please enter the height: “)    width = input(“Please enter the width: “)    area = height*width    print “The area is”, areaelse:    radius = input(“Please enter the radius: “)    area = 3.14*(radius**2)    print “The area is”, areaI've been trying to get this to work.  I was on a forum on Google and they said to put:input("press ENTER to continue")at the end.  I did, but it didn't work.  It runs the program but just shuts itself off when its done and i don't even get to select any of the option things that i'm s> upposed to be able to select.  It just turns on then back off and I don't even get to see anything.  Could someone help me out.ThanksAdam> > _________________________________________________________________> > Create the ultimate e-mail address book. Import your cont> acts to Windows Live Hotmail.> > www.windowslive-hotmail.com/learnmore/managemail2.html?locale=en-us&ocid=TXT_TAGLM_HMWL_reten_impcont_0507> > > > > > ------------------------------------------------------------------------> > > > _______________________________________________> > Tutor maillist  -  Tutor at python.org> > http://mail.python.org/mailman/listinfo/tutor> > First, welcome to the world of Python. :D> Second. please give a title when you start a new thread on a mailing list.> Third, format your posts and code. Since Python uses indented code, it's > kinda hard to read it when it's all in one line (Don't worry, I'll paste > it indented in a file attached to this email :D )> > Now for the code.> > After arranging the code, the first thing I noticed were this characters “ ”> > I tried running the code, and if gave me a error there, so I just > replace then with " ", and voilá, the code worked :D . So the lesson > here is always use either " " or ' ' in the code.> > Oh, a> lso another thing. Don't use input() to get the user input, because > that command can run code and it may be evilly used. Always use > raw_input() instead :D .> > Anyway, I hope I helped you,> > > -- >                         _> ASCII ribbon campaign ( )>   - against HTML email  X>               & vCards / \> > _________________________________________________________________> > Create the ultimate e-mail address book. Import your contacts to Windows Live Hotmail.> > www.windowslive-hotmail.com/learnmore/managemail2.html?locale=en-us&ocid=TXT_TAGLM_HMWL_reten_impcont_0507> > First of all, what email client are you using?> Because the text is getting all weird and difficult to read (it's all in > one line, with no paragraphs and things like that).> > Now, the thing about input() and why it's not a good policy to use is > that, unlike raw_input(), what type in a input() is executed by Python > (in raw_input() is stored as a string).> > Example:> > var = raw_input()>  >> list("LOL")> > Now we have a variable called var which contains the string that says > 'list("LOL")'> You can confirm that by typing:> print var>  >> 'list("LOL")> > There, no harm done. Now let's try the same thing using the input() command:> > var = input()>  >> list("LOL")> > Now let's type "print var" again as we did before.> > print var>  >> ['L', 'O'. 'L']> > Now what happened? Because you used the input() command, what you type > was interpreted by Python, instead of being stored in a string and since > the list() command is used to create a list, Python did just that. He > created a list. Now, in this example, no harm was done. But image > someone typing the command os.system("command to delete some file or run > some file"). That would send a delete command to the terminal, or > install some file (it could even be a virus).> > Ok, it's a little harder to explain, but the thing you should is that > usually raw_input() = GOOD, input() = BAD.> > > > > Now, I couldn't quite understand the second problem.> Please explain a little better.> > PS: Now I know why I see all posts messed up. It's because you're > sending your emails as a HTML, and I deactivated that on my email > client. I don't know if Hotmail (I believe you send you emails from > there) as an option to turn off HTML. If it was please use it :D> (Besides being nice, you can get more responses if you do that. Not > everyone has an HTML capable email client.)> > PS2 (no, not the console): I just noticed you didn't send the email back >   to the mailing list. You should select reply to all (or a similar > option) when replying to mailing list, so that other people can learn too.> > > > -- >                         _> ASCII ribbon campaign ( )>   - against HTML email  X>               & vCards / \
Change is good. See what’s different about Windows Live Hotmail.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070523/6042a68d/attachment.html 

More information about the Tutor mailing list