Commits

Shashank Bharadwaj committed 2a7583d

more stuff

  • Participants
  • Parent commits 8a3f3c2

Comments (0)

Files changed (2)

 *.pyc
 *~
 *\#
-*.\#*
+*.\#*
+*.class

pycon-2013/slides.md

 Outline of this talk
 =====================
 
-* How to use Java classes in Jython
+* Using Java classes from Jython
+* How to use Jython objects in Java
   - Using Java scripting API provided via JSR-223
   - Object factories
 
 Imported Java classes are Mutable [2]
 =====================================
 
+First compile the Java file
+
+    $ javac PyCon.java
+
+Now, you are ready to use it
+
     >>> import PyCon
     >>> def greeting(self):
     ...     print 'Welcome to PyCon %s' % self.getYear()
     >>> p.greeting()
     Welcome to PyCon 2013
 
+
+But, you cannot delete or update existing fields
+================================================
+
+    >>> del p.year
+    Traceback (most recent call last):
+      File "<stdin>", line 1, in <module>
+    TypeError: readonly attribute
+
+    >>> dir(p)
+    ['__class__', '__copy__', '__deepcopy__', '__delattr__',
+    '__doc__', '__eq__', '__getattribute__', '__hash__',
+    '__init__', '__ne__', '__new__', '__reduce__',
+    '__reduce_ex__', '__repr__', '__setattr__',
+    '__str__', '__unicode__', 'class', 'equals',
+    'getClass', 'getYear', 'greeting', 'hashCode',
+    'notify', 'notifyAll', 'toString', 'wait', 'year']
+
+
+<!-- Do we need to discuss how these classes are implemented in Jython?
+-->
+
+Copy of Table 10-1 fom Jython Book
+==================================
+
+<!-- Just putting this here in case we need to use it -->
+
+
+Java Type                         Python Type
+---------                         -----------
+char                              String
+boolean                           Integer
+byte, short, int, long            Integer
+java.lang.String, byte[], char[]  String
+java.lang.Class                   JavaClass
+Foo[]                             Array
+java.lang.Object                  String
+org.python.core.PyObject          unchanged
+Foo                               JavaInstance