Considering migrating to Python from Visual Basic 6 for engineering applications

Steven D'Aprano steve at
Mon Feb 22 06:16:38 EST 2016

On Mon, 22 Feb 2016 12:16 am, 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

I can't say I really know what that means. My guess is that reads three
things (a, b and c) from a file f, but what those things are (strings,
binary blobs, floats, ints, something else?) is a mystery.

One of the major problems with output parameters is that it isn't obvious
what is an output parameter and what isn't. When it comes to read, perhaps
you can guess, but when it comes to arbitrary functions, who can tell what
is output and what is input?

fromaginate m, x, y, z, a, b

Whereas a functional design makes it obvious: output is on the left of the
assignment symbol, input is on the right.

x, y, z = fromaginate m, a, b

> 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)
> 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).

Python doesn't have reference parameters.

Please feel free to discuss further if you disagree, or want additional

> (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!

Hmmm, well, yes, I think perhaps it is fair to say that there is middle
ground where Python misses out.

Python's raw IO is quite powerful, and it can handle unstructured binary of
text files with no difficulty.

It also comes with libraries for certain common file formats, like CSV, XML,
JSON and others.

But there's a middle ground, of *minimally structured* text files, where
Python leaves it up to you. Admittedly it's not difficult, any minimally
competent Python programmer should be able to read a bunch of ints or
floats from a text file without working up a sweat, but beginners may find
this tricky.

So I think you are right: there is a narrow, but useful, niche of
semi-structured textual data that BASIC and VB support that Python doesn't
support out of the box.


More information about the Python-list mailing list