From: Brad C. <bk...@mu...> - 2002-03-15 03:09:03
|
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 |
From: Syver E. <syv...@on...> - 2002-03-15 13:30:45
|
"Brad Clements" <bk...@mu...> writes: > Next week I need to give a one hour presentation at Novell's > Brainshare titled: > > "Rapid Application Development with Jython". > 3. Quick examples that I can type interactively that demonstrate the > power of the interpreted, typeless nature of Jython. I always found Jython excellent for investigating unfamiliar API's. Maybe you can use some JAVA api for an example. Maybe some JDBC stuff? A minor quibble, Jython is strongly typed not typeless. But it is dynamically and not statically typed (but you already knew that). I think that (J/P)ython is very different from languages were all the objects are autocasting themselves in that you aren't aware of what types are really used before something goes Ka-Boom, Jscript and VBScript springs to mind. -- Vennlig hilsen Syver Enstad |
From: Stephen N. <ste...@co...> - 2002-03-15 15:43:23
|
I intend to code a Graphical User Interface using Jython. I would like to structure the GUI class design using Object Oriented priniciples. I have looked at some design patterns, inparticular Model-View-Controller (MVC) and HMVC. Do any of you have any recommendation as to how to structure the GUI? Thanks Stephen |
From: Stephen N. <ste...@co...> - 2002-03-19 15:30:04
|
I'm porting some Java code to Jython. How woould I write a synchronised block? synchronized(some_object){ //code } Thanks Stephen |
From: Samuele P. <pe...@in...> - 2002-03-19 16:32:53
|
From: Stephen Naicken <ste...@co...> > I'm porting some Java code to Jython. How woould I write a synchronised > block? > > synchronized(some_object){ > //code > } > > Thanks > > Stephen For methods: import synchronize class C: def m(self): ... stuff ... m = synchronize.make_synchronized(m) For you specific idiom: you should put code in local/global function or use lambda and from synchornize import apply_synchronized def code(): ... # your code ... apply_synchronized(some_object,code,()) # apply_synchronized(some_object,lambda: code,()) regards. |
From: Samuele P. <pe...@in...> - 2002-03-19 16:48:11
|
[me on synchronize built-in module] obviously that was the direct translation, otherwise you can use the synchronization primitives of python threading.py: http://www.python.org/doc/2.1/lib/module-threading.html Or look at this Ype Kigma's post: http://aspn.activestate.com/ASPN/Mail/Message/828840 regards. |
From: Ype K. <yk...@xs...> - 2002-03-19 17:53:40
|
Stephen, >I'm porting some Java code to Jython. How woould I write a synchronised >block? > >synchronized(some_object){ > //code >} Have a look at http://mail.python.org/pipermail/jpython-interest/2000-August/003718.html It contains an example on how to synchronize a method on the object it is invoked on. You can also use a Lock from the thread module and explicity acquire and release it. This could be a bit slower, but it's more straightforward when your code is not a complete method. If you need the performance of the java synchronized construct, you can also leave the code in java. >Thanks My pleasure, Ype -- |
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 > |
From: Syver E. <syv...@on...> - 2002-03-16 16:42:06
|
"Brad Clements" <bk...@mu...> writes: > On 15 Mar 2002 at 14:29, Syver Enstad wrote: > > A minor quibble, Jython is strongly typed not typeless. But it is > > dynamically and not statically typed (but you already knew that). I > > Good point. It is an important distinction. Yeah, not least because there are some people out there that have made up their mind that strong typing is good, weak typing is bad. They tend to look at that in terms of static/dynamic typing, so it's nice to be able to whack them on the head with: python is indeed strongly typed, it's just that it is dynamically typed :-). -- Vennlig hilsen Syver Enstad |