July 16th, 2001, 03:34 AM
unsure of how it all works
I have been looking at the 101 tutorials and am finding them quite useful. However, i have only read parts 1-3 so far. I am just a bit unsure of how you call a python script from a web page though.... I am coming from a php background and the way I see it at the moment is that you put your python script in cgi-bin and then call it directly from there... am I correct in thinking this? what needs to be setup (say with apache) in order to use python?
Also, I am just wondering what the advantages of using python over php would be?? I have read some where that python is a proper OO language - is this all?
thanks in advance,
Comments on this post
July 16th, 2001, 08:28 AM
I've been using Perl as a scripting language for a couple of years and I'm new to web development. Last month, I started learning Python and really like the language. As such, I'm not a guru capable of answering your questions based on years of personal experience. If you know PHP and can do everything you want to do in it, I don't know of any particular reason you would want to switch to Python. In my case, I'm interested in learning OO programming techniques and figured this would be a good language to learn on. If you haven't looked a Zope (www.zope.org) which is an Open Source web application server written in Python, you might want to check it out.
--First-class functions and first-class everything else. Functions, methods, modules, classes, and other components of Python programs may be passed to functions or stored in data structures.
--Object orientation with multiple inheritance and late binding. Python allows creation of object-oriented class hierarchies, and the object referred to by name.attribute is determined at run time via a dynamic name search. For example, as demonstrated in the chapter on generating HTML, these features allow straightforward expression of complex computational concepts, and a high degree of code-reuse.
--Object-oriented and named exception handling. Errors or other exceptional conditions in Python programs can be trapped using try..except statements, and finalization actions can be specified using try..finally. This greatly simplifies code that may encounter exceptional conditions that interrupt the normal flow of control of the program. Exceptions may also be organized into inheritance structures.
--Dynamic calling sequences. Python callable objects can accept optional arguments, keyword arguments, or unlimited numbers of arguments. These features allow very generic and highly configurable operations to be implemented in terse Python declarations.
--Extendible: Python can be easily extended with interfaces to external programming libraries or new data types via compiled extension modules. Adding new compiled components to Python is easy -- much easier than writing stand-alone compiled programs. On most major platforms new compiled components may also be loaded into the interpreter dynamically, on demand.
--JPython is a re-implementation of Python in Java that compiles Python code into Java bytecodes. The resulting environment has very tight, almost seamless, integration with Java. It's trivial to access Java classes from Python, and you can write Python classes that subclass Java classes. JPython can be used for prototyping Java applications in much the same way CPython is used, and it can also be used for test suites for Java code, or embedded in a Java application to add scripting capabilities.
--New standard library features such as Unicode and XML support.
July 16th, 2001, 07:41 PM
Thanks for your quick response - it was very helpful!! I think I am going to still read on more about python. With a bit of experience with php's OO I was looking for something a bit better. I found your links very helpful and as I read through them I am sure things will fall into place. Thanks again for your help.......