Why does my compiler say invalid syntax then highlight...?

Nathan Pinno MadComputerGuy at gmail.com
Tue Mar 11 22:50:01 EDT 2008


On Mar 11, 1:12 pm, Mensanator <mensana... at aol.com> wrote:
> On Mar 11, 3:36 am, Duncan Booth <duncan.bo... at invalid.invalid> wrote:
>
> > Mensanator <mensana... at aol.com> wrote:
> > > On Mar 10, 10:44‹¨«pm, Nathan Pinno <MadComputer... at gmail.com> wrote:
> > >> Why does my compiler say invalid syntax and then highlight the
> > >> quotation marks in the following code:
>
> > >> # This program is to find primes.
>
> > > Needs work.
>
> > Be fair.
>
> Being helpful isn't fair?
>
> > The OP hadn't managed to figure out why the program wasn't
> > running, so you can't expect him to have got all the bugs out of the code
> > yet.
>
> The bug had already been answered.
>
> If you fail to implement your premise correctly, you have a bug.
>
> It doesn't matter if the code is bug-free if the premise is false.
>
> In this case, the premise that he can determine primes this way
> is false. He will have to abandon the cos() thing, for although it
> works in theory, he'll never get it to work in practice.
>
> Besides, the cos() is a red herring (hint: cos(pi*n)). The problem
> can be made to work EXACTLY (at least up to z=10000) by using
> rationals
> (which gmpy supports).
>
> His problem is going to take much more than fixing a syntax error.
>
> > And he only asked about the specific syntax error not the entire
> > solution to his homework.
>
> If this is indeed homework, and he's supposed to come up with a
> factorial algorithm, I seriously doubt the teacher would accept
> gmpy.fac(z-1), so I assume it isn't.
>
>
>
> > My advice to Nathan would be:
>
> > 1. If you get a weird syntax error that you don't understand try cutting
> > the code down to just the bit which generates the error.
>
> > 2. Play around in the interactive interpreter to see what works and what
> > doesn't.
>
> > 3. If you don't understand why the code doesn't work then get a stuffed
> > toy, cardboard cutout of a person, or the least technical member of your
> > family and explain to them in great detail exactly why the code must
> > (despite error messages to the contrary) be correct. Usually you'll spot
> > the problem half way through the explanation.
>
> > 4. If you post to this list then post the full error message and traceback.
> > That way we don't have to guess which quotation marks are the problem.

Yep, got it fixed, and no, it is not a homework problem...just a
project for fun to keep up my Python coding in my memory intact
(apparently, it doesn't work as well when I've been up early 3 days in
a row... :P ).

Now I just have to figure out why it isn't working the way it is
supposed to. It was given to me by someone in the sci.math area as an
alternative to working with 1 < x < n.



More information about the Python-list mailing list