Skip to content

Commit a96bdcd

Browse files
committed
Better snippets in the README
1 parent c6ee385 commit a96bdcd

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

README.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ Unmarshalling of Java serialised object:
7878
7979
import javaobj
8080
81-
jobj = self.read_file("obj5.ser")
81+
with open("obj5.ser", "rb") as fd:
82+
jobj = fd.read()
83+
8284
pobj = javaobj.loads(jobj)
8385
print(pobj)
8486
@@ -88,10 +90,11 @@ Or, you can use Unmarshaller object directly:
8890
8991
import javaobj
9092
91-
marshaller = javaobj.JavaObjectUnmarshaller(open("objCollections.ser"))
92-
pobj = marshaller.readObject()
93+
with open("objCollections.ser", "rb") as fd:
94+
marshaller = javaobj.JavaObjectUnmarshaller(fd)
95+
pobj = marshaller.readObject()
9396
94-
self.assertEqual(pobj.value, 17)
95-
self.assertTrue(pobj.next)
97+
print(pobj.value, "should be", 17)
98+
print(pobj.next, "should be", True)
9699
97-
pobj = marshaller.readObject()
100+
pobj = marshaller.readObject()

0 commit comments

Comments
 (0)