We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
The question says it all. I have sketches coded in Python via Python Mode that I'd like to convert to raw Processing programming language (.pde file). Is that possible ? If so, how could I make the conversion ?
Regards
Answers
There isn't an automatic method that I'm aware of. @jdf might know If contacted through processing.py on GitHub.
In some cases, manual conversion is as simple as adding semicolons to the end of lines and changing function declarations -- it depends on how complex your .py sketch is and if you are mainly just calling the processing API (easy) or if you are using Python-specific imports (like itertools) and idioms (like list comprehensions) (harder).
To get Java classes that you could adapt back into Processing (although this might be harder than hand editing) you can run your code through Jython and inspect the class files it generates, or you could try (untested) calling the processing.py Jython and use compileall or py_compile; see:
Thank you. I personnaly use a lot of list comprehensions so I guess the task won't be easy.
In that case, if there are any generic methods of automatically converting Python into Java, they might work for you. That sounds like it might already be a StackOverflow question somewhere....
This is how I've converted this array initialization loop from this Java Mode sketch below: ~O)
http://Studio.ProcessingTogether.com/sp/pad/export/ro.9AqEIV-5Q9sCx
To Python Mode; turning that whole loop as a 1-statement comprehension: :ar!
https://Forum.Processing.org/two/discussion/14071/converting-java-code-to-python-for-dataviz#Item_13