Re: [Tutor] Help with class example
Ramit Prasad wrote: > You would be better off trying to run this from the command > line. I just wanted to clarify on this. The reason you will have a better results running this from the command line is that Python will normally give you very good error traceback. An IDE might hide or obscure the problem, but it should be fairly easy to figure out if you see the error traceback. The error will usually be on that line, but sometimes (especially with syntax errors) it might be the line (or two) previous to the line shown. If you do not know how to run on the command line, post back letting us know (and what operating system) and we can guide you. It is not difficult but can sometimes be awkward or intimidating for people. Ramit This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with class example
On 11/05/2012 06:07 PM, Prasad, Ramit wrote: > Frank Pontius wrote: >> Sent: Saturday, October 27, 2012 12:27 PM >> To: d...@davea.name; bgai...@gmail.com >> Cc: tutor@python.org >> Subject: Re: [Tutor] Help with class example >> >> Here ya go! >> Can't do what you want as this is a programmatic error from interrupter. >> Only a screen shot will tell you the >> full situation. I have class example which is to be used for our homework, >> and I copied it into IDLE and it >> won't work, with error below. I've tried several ways to work around this >> >> Thanks >> Frank >> > > You would be better off trying to run this from the command > line. The problem is the "if" and "else" lines are indented one > level too far. If you match them with the previous line > it should work just fine. > > ~Ramit And the other problem is that the source in the OP message does not match the source in the jpg file. A line was omitted during the retyping. -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with class example
Frank Pontius wrote: > Sent: Saturday, October 27, 2012 12:27 PM > To: d...@davea.name; bgai...@gmail.com > Cc: tutor@python.org > Subject: Re: [Tutor] Help with class example > > Here ya go! > Can't do what you want as this is a programmatic error from interrupter. > Only a screen shot will tell you the > full situation. I have class example which is to be used for our homework, > and I copied it into IDLE and it > won't work, with error below. I've tried several ways to work around this > > Thanks > Frank > You would be better off trying to run this from the command line. The problem is the "if" and "else" lines are indented one level too far. If you match them with the previous line it should work just fine. ~Ramit This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with class example
On 10/27/2012 4:51 PM, Frank Pontius wrote: But, this is an if. When replying please put your response after the text it applies to, and delete all irrelevant text. In other words avoid "top-posting". Sorry I really messed up my reply! The offending line is: coin = random.randragge(0,2): get rid of the colon. That is used only at the start a compound statement e;g; if, else, for, while, def class, ... -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with class example
On 10/18/2012 07:59 PM, Frank Pontius wrote: > Hello, > I'm taking a beginners course on Python. > > Have class example which is to be used in H/W, which I can't get to work. > Thus I figure the example is wrong. But I need this to get H/W done. > > Using 'import random' and random.randrange in function, returning #. > > import random > > def RandomNumberGen (): > if random.randrange(0, 2) == 0: > Xreturn "tails" > return "heads" > > > Simple enough, but running in my Python 2.7.3 IDLE - it will not even run, > and give syntax (red char box) error at the X above. > > Frank > > So why is there an X there? As the compiler tells you, that's a syntax error. The return statement starts with an 'r' Please use only text editors to edit code, and use copy/paste to copy the actual source to your message, while composing the message in text mode. We cannot tell who has mangled the code, but only how it happens to look after the mangling is finished. If it ever goes through a word processor, or through an html message (which your is), then all bets are off. Another thing. Copy/paste the actual error message, including the traceback. Don't summarize it, or paraphrase it. -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with class example
On 10/18/2012 7:59 PM, Frank Pontius wrote: Help with class example Hello, Hi - this just showed up in my mailbox. Perhaps there was a delay getting it posted. The "" around tails and heads are not ascii quote characters. They are what some word processors change ascii quotes into to meet typesetting requirements. Use a text editor, or type the code directly into IDLE. I'm taking a beginners course on Python. Have class example which is to be used in H/W, which I can't get to work. Thus I figure the example is wrong. But I need this to get H/W done. Using'import random'and random.randrange infunction,returning #. import random def RandomNumberGen (): if random.randrange(0, 2) == 0: Xreturn"tails" return"heads" Simple enough, but running in my Python 2.7.3IDLE-it will not even run,and give syntax(red char box)error at the X above. Frank ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Help with class example
Hello, I'm taking a beginners course on Python. Have class example which is to be used in H/W, which I can't get to work. Thus I figure the example is wrong. But I need this to get H/W done. Using 'import random' and random.randrange in function, returning #. import random def RandomNumberGen (): if random.randrange(0, 2) == 0: X return "tails" return "heads" Simple enough, but running in my Python 2.7.3 IDLE - it will not even run, and give syntax (red char box) error at the X above. Frank ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor