[Tutor] converting processing code to python code

Alan Gauld alan.gauld at btinternet.com
Tue Dec 2 02:23:59 CET 2008


"Erica Osher" <eosher at gmail.com> 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 fact that you still don't tell us what the original language is 
suggests
you are not a very experienced programmer in any language. Is that
assumption correct?

> 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;
>          ^
> SyntaxError: invalid syntax

In Python variables are just names that refer to objects. The objects
can be of any type so we don't need to declare them as int, float,
char etc. You just need

x1 = 5

No semi colons are needed either.

However since this is such a basic Python statement I do think
you should take an hour or two to go through some of the complete
beginners tutorials found here:

http://wiki.python.org/moin/BeginnersGuide/NonProgrammers

Try mine if you like but there is a variety of styles for you to 
choose from.

Once you are familiar with the basics try converting your code again
and ask specific questions here for help. That will be much more
efficient for all of us than simply randomly trying things then asking
for help.

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list