[Tutor] converting processing code to python code

Steve Willoughby steve at alchemy.com
Tue Dec 2 00:45:25 CET 2008


On Mon, Dec 01, 2008 at 06:40:03PM -0500, Erica Osher wrote:
> The code was originally created for a Processing Project and I'm just
> starting to learn python and I'd like to build on this code.
> 
> The syntax error I get is
> 
> *Traceback (most recent call last):
>   File "nodebox/gui/mac/__init__.pyo", line 332, in _compileScript
>   File "<untitled>", line 8
>      int x1 = 5;

That's not even close to Python syntax.  That looks 
like a C-derived language.  I'd recommend going through
a basic Python tutorial first, so you can see how Python
works in a general sense before trying to convert code.

In Python, you don't need to declare variables like
that, you just assign them values.  So that line would
be simply:

  x1 = 5


>  SyntaxError: invalid syntax
> *
> any suggestions?
> 
> Thanks.
> 
> On Mon, Dec 1, 2008 at 6:30 PM, Alan Gauld <alan.gauld at btinternet.com>wrote:
> 
> >
> > "Erica Osher" <eosher at gmail.com> 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.
> >>
> >
> > It would help to have some background.
> > What language are you translating from? It could be C/C++/JavaScript or
> > Java.
> > Or possibly other C type languages. It might be significant!
> >
> > Also show us what you tried and the syntax error messages.
> > That way we can figure out what it is you are doing wrong.
> >
> > Otherwise we wind up writing your code for you and you learn nothing.
> > Then we have to do it all o er again next time you get stuck.
> > That's inefficient for both you and us!
> >
> >
> > --
> > Alan Gauld
> > Author of the Learn to Program web site
> > http://www.freenetpages.co.uk/hp/alan.gauld
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
> 
> 
> 
> -- 
> Erica Osher

> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor


-- 
Steve Willoughby    |  Using billion-dollar satellites
steve at alchemy.com   |  to hunt for Tupperware.


More information about the Tutor mailing list