From: Kevin B. <kb...@ca...> - 2001-06-22 19:49:47
|
The problem is you're passing a String (containing a space-separated list of strings) into a method that expects a String array. try: ...main( string.split( "10 100" )) tuples or lists of strings should be coerced automatically to String arrays. For some complex cases involving arrays, you may need to investigate the jarray module, but most of the time the automatic coercion of sequences to arrays works fine. kb "W. Jarrett Campbell" wrote: > Hello. I've been using Python for a short while and one of my > developers is insisting he'd prefer to supply me with Java classes > rather than C++ classes so I'm contemplating making the jump to > Jython.We were running a simple benchmark test to see if we could this > system working for us and I've encountered a few problems. Could > someone here give me a few pointers?I'm trying to execute the > following method in Jython: public static void main(String[] args) { > try { > int count = Integer.parseInt(args[0]); > int arraySize = Integer.parseInt(args[1]); > ArrayBenchmark test = new ArrayBenchmark(); > test.setLength( arraySize ); > > long totalTime = test.repeat(count); > System.out.println("Array Benchmark: " + count + " iteration(s) > in " + totalTime + " milliseconds"); > } catch (Exception e) { > System.out.println("Exception: " + e); > e.printStackTrace(); > } > } > Every time I execute this command, I get a message that the String > coercion is failing. Any ideas?>>> > com.ydyn.dynamo.test.ArrayBenchmark.main('10 100') > Traceback (innermost last): > File "<console>", line 1, in ? > TypeError: main(): 1st arg can't be coerced to String[] > >>> > > [Image] W. Jarrett Campbell, Ph.D. 512.323.9149 Member of the office Technical Staff 512.257.9503 fax Yield Dynamics, 512.415.1078 Inc. mobile 5838 Balcones ja...@yd... Drive, Ste. 101 http://www.ydyn.com Austin, TX 78731 > |