From: Brian Z. <bri...@ya...> - 2002-03-15 18:13:03
|
Hi Brad, For 1 and 2, http://www.python.org/doc/essays/ppt/lwnyc2002/intro22.ppt seems very good. As to the example, IMO interactively explore some java API would open eyes for VB and Perl programmers. Features like built-in list, dictionary, slicing probably are easier to demonstrate than polymorphic dynamic OO. Here are some examples I often use: 1) java.vm.version >>> from java.lang import System >>> dir(System) ['arraycopy', 'currentTimeMillis', 'err', 'exit', 'gc', 'getProperties', 'getProperty', 'getSecurityManager', 'getenv', 'identityHashCode', 'in', 'load', 'loadLibrary', 'mapLibraryName', 'out', 'runFinalization', 'runFinalizersOnExit', 'setErr', 'setIn', 'setOut', 'setProperties', 'setProperty', 'setSecurityManager'] >>> props = System.getProperties() >>> props.__class__ <jclass java.util.Properties at 7576227> >>> props.__class__.__bases__ (<jclass java.util.Hashtable at 3325456>,) >>> for k in props.keys(): ... if k.startswith('java.vm.'): ... print k ... java.vm.version java.vm.vendor java.vm.name java.vm.specification.name java.vm.specification.vendor java.vm.specification.version java.vm.info >>> props['java.vm.version'] '1.3.1_02-b02' 2) exercise from SICP book in python >>> def subsets(aList): ... if [] == aList: return [ [] ] ... else: ... rest = subsets(aList[1:]) ... return rest + [ [aList[0]] + x for x in rest ] ... >>> subsets([1,2,3]) [[], [3], [2], [2, 3], [1], [1, 3], [1, 2], [1, 2, 3]] 3) swing calculator (put it in swingCalc.py) ############################################ # evaluation runs a full expression all at # once using the Python eval() built-in-- # interpreter is present at run-time ############################################ from java import awt # get access to Java class libraries from pawt import swing # they look like Python modules here labels = ['0', '1', '2', '+', # labels for calculator buttons '3', '4', '5', '-', # will be used for a 4x4 grid '6', '7', '8', '*', '9', '.', '=', '/' ] keys = swing.JPanel(awt.GridLayout(4, 4)) # do Java class library magic display = swing.JTextField() # Python data auto-mapped to Java def push(event): # callback for regular keys display.replaceSelection(event.actionCommand) def enter(event): # callback for the '=' key display.text = str(eval(display.text)) # use Python eval() to run expr display.selectAll() for label in labels: # build up button widget grid key = swing.JButton(label) # on press, invoke Python funcs if label == '=': key.actionPerformed = enter else: key.actionPerformed = push keys.add(key) panel = swing.JPanel(awt.BorderLayout()) # make a swing panel panel.add("North", display) # text plus key grid in middle panel.add("Center", keys) swing.test(panel) # start in a GUI viewer BTW, Thank you for the excellent PythonCE work, I really enjoy using it! -Brian ----- Original Message ----- From: "Brad Clements" <bk...@mu...> To: <jyt...@li...> Sent: Thursday, March 14, 2002 7:23 PM Subject: [Jython-users] Looking for Jython promo materials > Next week I need to give a one hour presentation at Novell's Brainshare titled: > > "Rapid Application Development with Jython". > > I'll be demo'ing Jedit, JythonInterpreter (plugin), JinSitu and of course Jython, on Win32 > and NetWare Systems. > > I have a simple Beans based application that I'll be showing, but I'm looking for some > other things: > > 1. Quick intro to the Python Language (10 minutes) > > 2. Perhaps a Power Point slide show for item 1 > > 3. Quick examples that I can type interactively that demonstrate the power of the > interpreted, typeless nature of Jython. > > I'm aware of what's available at python.org and jython.org, but if you have any other > recommendations I'd appreciate it. > > My audience will be in-experienced VB'ers/Perlers.. And experienced Java developers. > > Thanks for any suggestions, > > > > > Brad Clements, bk...@mu... (315)268-1000 > http://www.murkworks.com (315)268-9812 Fax > AOL-IM: BKClements > > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > |