Can Python work like Java Applet?

Alan Kennedy alanmk at hotmail.com
Wed Oct 22 11:51:18 EDT 2003


[Batista, Facundo]
>> Just don't get confused by the names. Browsers have embedded a 'Java
>> Applet' interpreter. You can't execute Java there.

[Jim Dabell]
> Of course you can, that's the whole point!
> 
> Anyway, to answer the original question, browsers don't have a built-in
> Python runtime, 

Actually, that's not strictly true. The win32all windows extensions
install a python interpreter COM object, which can used as a scripting
plugin with the Windows Scripting Host (WSH), meaning that one can
embed python in an HTML page, in the same manner as Javascript.

Documentation is here:

http://www.python.org/windows/win32com/ActiveXScripting.html

However, your script will only run on Internet Explorer browsers that
have python *registered* as a scripting language. Which is possibly
not a problem on an Intranet, where one can make's one's users install
the plugin, but is unlikely to have widespread support on the
Internet.

The "install" vs. "register" distinction is necessary because
registering python as a scripting language opens up some serious
security holes. Because python doesn't currently have a restricted
execution ("sandbox") environment similar to java applet-playing
plugins, python scripts embedded in pages displayed by Internet
Explorer have pretty much total control over the users machine. The
first report of that, with details of some potential attacks, can be
found here:-

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=3C44A774.5DFCDE15%40computerbytesman.com

> you can use JPython to
> construct a Java applet from Python sources.

An excellent solution. 

I would recommend to the OP to consider learning *both* java and
python at the same time, by learning jython. Others may strongly
disagree however.

regards,

-- 
alan kennedy
-----------------------------------------------------
check http headers here: http://xhaus.com/headers
email alan:              http://xhaus.com/mailto/alan




More information about the Python-list mailing list