convert python to java code

Magnus Lie Hetland mlh at vier.idi.ntnu.no
Mon Jan 7 23:01:40 CET 2002


In article <3c3a05aa at sys13.hou.wt.net>, Gordon Hollenbeck wrote:
[...]
>> For actual use, of course, the .class compiled JVM-bytecode file is
>> all you need, and your maintenance will be on the .py source anyway.
>
>Well, the project is written in Java by all the other Java coders (all
>source is .java files).
>I just want a faster way to code than putting in {'s...
>
>oh well, ill stick with java

Well, you could easily create a preprocessor yourself, if all you
need is some syntax simplification... Translating

  class Foobar(Babar):
      int frozzbozz(int x, String y):
          println("foobar")
          return 2

to

  class Foobar extends Babar {
      public int frozzbozz(int x, String y) {
          System.out.println("foobar");
	  return 2;
      }
  }

[Sorry if the indentation got messed up here; having problems with
my editor :P]

is pretty easy with a little Python script. All you have to worry
about is handling indentation, which can be a bit tricky. I have
an old module for that lying about here:

  http://www.idi.ntnu.no/~mlh/python/blockparser.py

I'm sure you can find ways of improving it :)

Good luck!

- Magnus (who has been thinking about creating simpler versions of
  Java and C/C++ himself...)

-- 
Magnus Lie Hetland                                  The Anygui Project
http://hetland.org                                  http://anygui.org



More information about the Python-list mailing list