On Mon, Dec 01, 2008 at 03:48:59PM -0500, Erica Osher wrote:
> I have a simple processing code that I'm trying to work with in python, but
> I keep getting syntax errors. Any help on changing the code would be greatly
> appreciated. Thanks.

Could you show us what you have so far in Python and what syntax errors
you get?

Just as one example, this would be
pretty straightforward to convert straight
to Python, syntactically.  Whether you'd 
want to restructure the application to be
more optimally "Pythonic" is another topic
depending on what else is going on (or is 
this the entire program)?

> void drawSquare1() {
>  if(x1<0 || x1>width-size) {
>   x1Speed = -x1Speed;
>  }
> 
>  if(y1<0 || y1>height-size) {
>   y1Speed = -y1Speed;
>  }

def drawSquare1():
  if (x1 < 0 or x1 > width-size):
    x1 += x1Speed
    y1 += y1Speed
    rect(x1, y1, size, size)

Is that the sort of code you're coming up with?

One thing that strikes me off the top here is that
(in either language) you'd be better off not using
all those global variables.  Make your functions take
parameters and use them in your calculations.


-- 
Steve Willoughby    |  Using billion-dollar satellites
[EMAIL PROTECTED]   |  to hunt for Tupperware.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to