Why a class when there will only be one instance?

Vineet Jain vineet at eswap.com
Thu May 27 18:28:59 EDT 2004


> Just a little observation:
> If you really want the class and the instance to be the same,
> well, you can take a module.
> In a sense, this *is* a class and the only instance.

I need to use BASIC language like scripting in a python application. The 
users are not programmers and the scripting interface needs to be 
as simple as possible. The script would have a init section
a run section a close section and some other parts as well. I 
have these sections defined as functions in a class (the class inherits
from a base class) currently but have a feeling that I'm going to have 
to simplify things. Am not sure how users will handle class, functions, 
self, import, etc.

I was thinking of using a module, but can I repeatedly call the module. 
If so how would I call it? Would I keep reloading it? Where does a module
store it's state information between calls? I was thinking of supporting 
different sections by setting different variables which the user would 
access it:

if init:
	do init code here

if run:
	do run here

if close:
	do close here

Any other ideas? I'm trying to keep the scripting interface as simple as
possible but at the same time give the users the power of python.

Thanks,






More information about the Python-list mailing list