[Edu-sig] Python @ Education: What are your problems?

Kirby Urner urnerk@qwest.net
Thu, 30 May 2002 09:13:39 -0400


> Input of whitespace separated numbers from file or stdin is relatively
>
> complex in Python:
> >>> line =3D raw_input()
> >>> snumbers =3D string.split(line)
> >>> x, y =3D float(snumbers[0], snumbers[1])
>
> unless I'm missing something obvious. The comparable expression in
> Pascal is
>
> readln(x, y)

True, more complicated, as per previous thread.

def readln():  # defined once
    return [eval(i) for i in raw_input().split()]

x,y =3D readln()  # used elsewhere

is a quickie workaround. =20

Seems if your goal is to get right to Physics and not master Python as a=20
language per se (i.e. Python is very much a means to an end), then=20
you could teach students to go:

   from courseware import *=20

at the top of their programs.   Inside of this module could be included
various shortcuts of this nature (e.g. readln).  This might save time
better spent on physics.  In other words, code up to a higher, yet more
specialized level, and use this customized API in class (the module=20
might well include some routines for Numeric and GnuPlot stuff).

Kirby