Yes, I defined a file under the Lib directory to run and set my environment, something  like this:
import sys
def help(name):
  if (name == "connect"):
    print 'This command lets you connect to the server"

The will be executed when you bring up an interactive session. I can do something like,
>>> help("connect")
And this will do what i want.
But my question is can I do something like,
>>> help connect
with out the enclosing brackets? Calling help("connect")  somehow doesn't seem natural. My users are complaining about that they do not want to call as if they are calling functions, they just want to be able to issue commands as if they are interacting with a command shell.
Can this be achieved?

Thanks for any help,

Updike, Clark wrote:
You can run a script in the environment that sets up the help function
before the interactive session takes over.  I use this to set up
lots of other stuff (database connections, app functions, variables)
for users.

I don't think the environment variable PYTHONSTARTUP (which runs the 
specified script in Python) does anything in Jython.  However,
this is how I achieve the same end.

FILE ----------------------------------------
# Sets up the custom command line environment.
# Can also run user scripts before going interactive.
# FYI: calling batch file must use -i switch to go to an 
# interactive session after running the user's script.

import sys
# set up help function
# users can run help on the function object: help(envFunc)
# or on the string name of the function:     help('envFunc')
def help(subject='help'):
   """help([,subject]) -> None
      Put your high level help documentation goes here:
      List of environments variables, functions, etc.

   if hasattr(subject,'__doc__'):

     print subject.__doc__ # passed in function ref


        exec("print " + subject + ".__doc__")
     except NameError, e:
        print "Nothing found by the name '" + subject + "'"

# set up anything else you want (variables, other fuctions, etc.)

# run user's script if present (argv[1])
if len(sys.argv) > 1: 

   print 'Script %s has run' % sys.argv[1]

FILE PyLaunch.bat ------------------------------------

C:\APPS\jython-2.1\jython.bat -i %1 %2 %3 %4 %5 %6 %7 

Then, to start up the interactive session with the help function
present, just run the bat file: 


C:\temp>C:\APPS\jython-2.1\jython.bat -i
help([,subject]) -> None

      Put your high level help documentation goes here:
      List of environments variables, functions, etc.


If you set up resources like database connections, be sure to use
a try/finally construct in to clean up after exceptions.

Good luck,

-----Original Message-----
From: Satya Ghattu []
Sent: Thursday, July 17, 2003 6:04 PM
To: ''
Subject: [Jython-Users] Defining commands in the shell ....

Hello there...
I am not sure if this is achievable in Jython interactive shell but 
would like to know for sure ...
Can I define 'commands' in jython that I can execute when a user types 
it on the interactive shell?
For example, I would like to define a 'help' command that shows the user 
some basic help about my application. So, the user can just type,
 >>> help
on the command prompt. And also can these commands take additional 
arguments, like ...
 >>> help connection
which should display help about connecting to my application.

Thanks for any help,

This email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here:
Jython-users mailing list