Advice - Learning Python as 1st Programming Language

Alex Martelli alex at magenta.com
Tue Aug 8 04:10:31 EDT 2000


"Desmond DSouza - @austin.rr.com>" <<firstlast> wrote in message
news:rDJj5.3660$KO2.96211 at typhoon.austin.rr.com...
> I am advising a non-programmer on how to get started with programming. I
> would like opinions about his learning Python as a 1st programming
language:
>
> - Would it be better from learning perspective than, say, Java or
> Javascript?

I think it would be, but there's a radical split of opinion about the
best way to learn programming.  The "bondage and discipline" school
insists that it's best for the language to constrain the student (so he
or she can be made to do what's good for him/her); for that school,
Java, with somewhat-strong typing, would be preferable (though not
as good as Pascal derivatives, including Eiffel, Sather, &c, with even
stronger typing).  The "flowers' children" school insists that the best
language is the one that is as unobtrusive as possible, enforcing no
such discipline; Python is outstanding in that group (there are other
very good such languages, but Python is my favourite) -- it does have
strong typing, but it's dynamic, and with no redundant declarations,
leading, IMHO, to an optimal learning experience.

I suspect that what school is going to be most effective will depend
on the individual learner.  FWIW, I've learned (lo those many years
ago) mostly on the B&D lines (Pascal; I was, admittedly, also using
Fortran and APL 'on the side', and a little bit of Lisp, and... but
Pascal was my "daily bread"), but have recently switched sides, and
now think that more fluid languages are better for most people;
more rigid typing has its place, I still think (e.g. it can help get best
performance on critical parts of a project; maybe it can help keep
track of things on very large projects), but is not appropriate, IMHO,
for most beginners.

Javascript is another issue, and I definitely don't want to start any
flamewar, but I, personally, emphatically dislike it.  With so many
_good_ scripting languages, why focus on JS...


> - Is there any useful yet simple IDE available for Windows 98?

Two of them that I know of (plus, no doubt, more of them around):
IDLE, the very good portable IDE that comes with standard Python;
and PythonWin, the Windows-specific IDE that comes with Hammond's
win32all Windows extentions -- the latter has more of a "typical
Windows look & feel", though IDLE has portability advantages.

> - Any way to embed Python in web pages, like JavaScript? Or would he have
to
> learn 2 languages?

Client-side: when Python, and Hammond's extensions, are installed,
then Python satisfies Microsoft's definition of an "Active Scripting
Language" -- thus it can be used wherever Active Scripting is
supported.  Inside web-pages (viewed with Internet Explorer 4
or better), in the Microsoft Scripting Host, from applications that
host a Microsoft ScriptControl, etc, etc.  The practical limit, if you
serve pages to just-anybody over the internet, is that you generally
don't dare require every client to have a decent browser install, so
many pages are coded to a very low common denominator -- the
small subset of HTML (not very dynamic) and Javascript (ecch) that
Netscape and IE both support.  So, advanced features (Dynamic
HTML, the DOM, CSS, _and_ decent client-side scripting) are most
often limited to intranet settings (where there IS some control on
client installations!).

Server-side: Python can be used on Microsoft ASP (Active Server
Pages, with their IIS server) just as any other Active Scripting lang.
But there are a zillion other solutions, not limited to MS platforms.

JPython (the Python version that compiles to JVM bytecode, see
www.jpython.org) can be used wherever Java can (servlets,
applets, whatever).  This may be good for both server-side and
client-side though it's not normally code 'embedded' in the
webpage itself (rather, .class files, maybe grouped into a .jar,
'on the side').

Then there are many other solutions for 'embedding' (server
side), generally modeled roughly after the ASP concept but
with enhancements (and based on Apache most of the time).
One, for example, has been written up as "JSP" in Dr Dobb's
Journal (and relies on JPython), but there are many others.


> - Any good libraries for web CGI-like calls to Python (don't really care
at
> this point if it uses CGI-like mechanisms or something more efficient)?

    import cgi

lets you do cgi stuff very simply indeed.  The cgi module is part
of Python's core distribution.  Then there are a zillion add-ons for
more sophisticated stuff (fast-cgi, long-running-web-processes,
etc; HTML generation in any variant you can imagine; etc, etc).

> - Any good libraries for working with SQL databases?

Oh yes.  mxODBC, rather than the bundled odbc module, seems to
be better if ODBC interfaces are what you want, and there are also
implementations of the same Python-side interfaces (the standard
Python database API) for many different databases (postgres,
oracle, mysql, etc, etc), including one, Gadfly, that's entirely written
in Python (with a little optional performance help from C modules)
and is blazingly fast for small databases with single-user access (it
cheats by reading them all into memory:-).

Plus, on Windows only, one can easily use ADO and access the
whole Microsoft Universal Data Architecture that way, if one
prefers -- but then portability to Linux, etc, is impaired (apart
from that, ADO + ADOX is an excellent architecture, not for
_relational_ data only -- access OLAP, LDAP, XML stuff, whatever,
all with the same simple and powerful object-model...).

> - Any good libraries for building things like page template (e.g. ASP,
JSP,
> ...)

See above, but, summing up: yes, you can do ASP _and_ JSP, plus
a zillion other alternatives.

Many people swear by ZOPE, the Python-written web application
server engine, which offers a lot besides 'page templates'; some
have written it up as "Python's Killer-Application".  But Python is
really outstanding at "working with others"... you can do your own
HTTP serving in Python itself (a couple of such servers come with
core Python, plus, MEDUSA is truly outstanding, also in Python),
work with ASP (IIS, fast-cgi, plain cgi), Apache (mod_python, mod_snake,
PyApache, fast-cgi, plain cgi), Xitami (LRWP, with either serialized
or multithreaded Python to respond to requests, or, of course, plain
cgi again), and no doubt a zillion other ways -- indeed, the huge
freedom of choice Python gives you can even be seen as a problem
("which one is right for me" being a natural question!-).  But it does
smooth things when (as most often in the real world) there are
external constraints, e.g. the server MUST be Microsoft IIS for some
political reason, etc, etc:-).


> If you email to me, in addition to the group, would be great.

No doubt, but you've omitted any indication of a valid email
address; the one in your headers is " <<first>-<last>@austin.rr.com>",
which I cannot write to.  So, sorry, but you made this request
impossible to comply with!


Alex






More information about the Python-list mailing list