The homepage contains the readme and the minitutorial with its output plus a screenshot from a tutorial run.
Back to sourceforge.net project main/download page.
jp scratchpad comes with an
executable jpython jar file jppad.jar, something
like
jpython -jar jppad.jar
should work to start it.
jppad-interest@lists.sourceforge.net
At the moment it is open for
posting for everyone.
I'm interested in constructive
comments or critics (maybe destructive too ;))
otherwise I will never be able
to improve it.
I will try to do my best effort
also to answer to related problems and questions
trough the mailing list.
This program
is free software; you can redistribute it and/or modify
it under
the terms of the GNU General Public License as published by
the Free
Software Foundation; either version 2 of the License, or
(at your
option) any later version.
This program
is distributed in the hope that it will be useful,
but WITHOUT
ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General
Public License for more details.
You should
have received a copy of the GNU General Public License
along with
this program; if not, write to the Free Software
Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA.
-- Mini tutorial
-- One can evaluate simple python
statements. Try pressing Shift+Enter
on the next line.
1+2
>>
3
-- Simple statement boundaries
are recognized. Try Shift+Enter on any
line of the following
statement.
for i in range(1,4):
print i,
print 2*i
>>
1 2
2 4
3 6
-- '--' starts comment/inactive
text chunks
Shift+Enter on a statement
invoke evaluation.
-- Multiple statements can
be put together and executed at once
gathering them in a block
starting with a '!' line and using
indentation. Let's do
some cleanup. As before Shift-Enter
somewhere on it.
!
print dir()
del i
print dir()
>>
['__doc__', '__name__',
'i']
['__doc__', '__name__']
-- Some more features.
First execute this assignment
a=3
>> ok
-- The output is None but you
still get an '>>ok' feedback.
Then try this block.
Do not erase the output.
!
a=a+1
print a
>>
5
-- Now try to press Shift-Enter
on one of the output lines ('>>',' 4').
The statement is evaluated
again and the output changed accordingly.
-- Error handling.
The next statement is
not lexically correct. Try Shift-Enter.
a=$+3
^Lexical error at line
1, column 3. Encountered: "$" (36), after : ""
-- This is not syntactically
correct. Try.
if
^invalid syntax
-- This statement should continue.
Try.
if a==6:
...
-- y is not defined raising
an exception. Try.
!
print a
y
>>
5**err*
**exc*
traceback (innermost
last)
File "<!>",
line 2, in ?
NameError: y
-- Line numbers make sense.
-- One can execute statements
in on-the-fly created modules.
First.
!module0
x=3
>> ok
-- Then try:
!
import module0
print module0.x
>>
3
-- The default module is:
print __name__
>>
__pad__
-- Unloading of java classes.
First one should set
a path where unloadable classes are
located. This can be
a set of directories and/or jar files and
must be disjoint from
the usual classpath.
There is an escape command
for this.
ex.: +dyn-class-path-append
[...]/y [...]/x.jar
For the tutorial we need
to reach the directory stuff/xper
of jppad installation.
Modify the following as necessary and
execute it as always
with Shift+Enter.
-- On Windows you need something
like x:/jppad/stuff/xper
+dyn-class-path-append /home/user/jppad/stuff/xper
>> ok
-- NOTE: The reloading/unloading
support for java classes is known to work
properly only under jdk/jre
1.3 !!! See the README file.
-- Notice: xper contains X.class,
X.clazz and X.java-v0, X.java-v1
that are the source code
for the two bytecode compiled classes.
Try the following.
!
import X
print X.v()
>>
version 0
-- With this esc command every
python-object defined in the session
is discarded and the
java classes from the dyn-class-path are unloaded
too.
+forget
>> ok
-- Note: The dyn-class-path
remains valid and set.
In order to discard it
too one should use
+forget-forget-dyn-class-path
-- Now try the following. Modify
the first line as necessary.
!
xper='/home/user/jppad/stuff/xper'
import os
def toggle():
os.rename(os.path.join(xper,'X.class'),os.path.join(xper,'X.cla__'))
os.rename(os.path.join(xper,'X.clazz'),os.path.join(xper,'X.class'))
os.rename(os.path.join(xper,'X.cla__'),os.path.join(xper,'X.clazz'))
toggle()
import X
print X.v()
toggle()
>>
version 1
-- More.
Attached to this window
there is a contextual popup with many
functions.
For example indent/dedent
which operate on the selection.
Ctrl-I, Ctrl-D do the
same.
Functions to include/export
text from/to files (ev. filtering the
outputs '>>...')
There is also an output
window and the popup contains actions
for redirecting the various
python or java err or out streams
here, to that window
or to the console.
E.g. per default java
System.err is redirected to the out-win.
Try.
!
from java.lang import
System
System.err.println('xx')
>> ok
-- And.
!
import java
raise java.lang.Exception()
>>
**err*
**exc (java)*
traceback (innermost
first)
File "<!>",
line 2, in ?
java.lang.Exception:
java.lang.Exception
-- Hack.
Before trying this use
the popup to redirect java out here.
xper should still be
in the dyn-class-path.
!
import Y # from xper,
the source is also there
import Z # from xper,
the source is also there
Z.sendSELmsg(Y())
a=3
>>
loading Y
loading Z
** Y *
+dyn-reload
>> ok
!
print a
Z.sendSELmsg(Y())
>>
3
loading Y
loading Z
** Y *
-- The semantics of +dyn-reload
is a bit hackward.
It reloads all classes
from the dyn-path, but no instances or
derived pyclasses should
be around and only names at top-level
in every module can be
bound to these classes and then get rebound
to the reloaded versions.
If something fails you get a feedback
on the involved classes
and you can fix it and issue a +retry.