Considering migrating to Python from Visual Basic 6 for engineering applications

Tim Chase python.list at
Sun Feb 21 13:19:06 EST 2016

On 2016-02-21 13:16, BartC wrote:
> > No need for anyone to re-invent the
> > wheel!  ;-)
> I keep seeing this in the thread. Python has all this capability,
> yet it still requires a lot of fiddly code to be added to get
> anywhere near as simple as this:
>    read f, a, b, c
> And this is code that is not going to be obvious to anyone starting
> out. Even accepting that syntax limitations might require this to
> be written as:
>    readline(f, a, b, c)

Well, if you know what the line is going to contain, that can be
written as

  a, b, c = f.readline().split()

> I can't see a straightforward way of making this possible while
> still keeping a, b and c simple integer, float or string types
> (because Python's reference parameters don't work quite the right
> way).

However, that does give you byte-strings since that's what comes out
of files.  If you know they're ints, you can force that:

  a, b, c = map(int, f.readline().split())

> (There is also the question of 'readline' knowing what types of
> values to read. This information would not be needed in Fortran or
> Basic but somehow needs to be supplied here, if a particular set of
> types is to imposed on the input.)
> In other words, it seems this particular wheel does require
> re-inventing!

In both Fortran & BASIC, you specify that information somewhere as
well.  However, it sounds like you define those at the
variable-definition level (it's been over a decade since I done any
BASIC and far longer since I've even touched any Fortran, so forgive
me if I'm a tad rusty) instead of where its read from the file.


More information about the Python-list mailing list