RSS feed
[root]
/
python
/
bruceeckel
/
com
/
code
/
TI Pattern
/
software design
/
document
login:
password:
title search:
Search this site
Enter your search terms
Web
www.carfield.com.hk
Submit search form
Prev
Next
Wed Dec 26 16:00:00 GMT 2001
Test
//: com:bruceeckel:python:Test.java package com.bruceeckel.python; import org.python.util.PythonInterpreter; import java.util.*; import com.bruceeckel.test.*; public class Test extends UnitTest { PythonInterpreter pi = new PythonInterpreter(); public void test1() { pi.exec("tup=('fee','fi','fo','fum','fi')"); List lst = PyUtil.toList(pi, "tup"); System.out.println(lst); System.out.println(new HashSet(lst)); } public void test2() { pi.exec("ints=[1,3,5,7,9,11,13,17,19]"); List lst = PyUtil.toList(pi, "ints"); System.out.println(lst); } public void test3() { pi.exec("dict = { 1 : 'a', 3 : 'b', " + "5 : 'c', 9 : 'd', 11 : 'e'}"); Map mp = PyUtil.toMap(pi, "dict"); System.out.println(mp); } public void test4() { Map m = new HashMap(); m.put("twas", new Integer(11)); m.put("brillig", new Integer(27)); m.put("and", new Integer(47)); m.put("the", new Integer(42)); m.put("slithy", new Integer(33)); m.put("toves", new Integer(55)); System.out.println(m); pi.set("m", PyUtil.toPyDictionary(m)); pi.exec("print m"); pi.exec("print m['slithy']"); } public static void main(String args[]) { Test t = new Test(); t.test1(); t.test2(); t.test3(); t.test4(); } } ///:~
(google search)
(amazon search)
1
2
3
second
download zip of files only
Prev
Next