I'm working my way through the Eric Matthes book on Python and I've encountered his discussion of lists. For example, code:
motorcycles = ['honda', 'yamaha', 'suzuki']
I used variable arrays a ton in Visual BASIC. They were useful for storing messages in different languages. For example, the 0 index was always English, 1 was French, 2 German, etc. I used a lot of string variable arrays and integers, though there were others.
So far it seems like I could use a list for exactly the same thing that I used to use variable arrays for.
Are Python lists essentially the same thing or am I going to encounter variable arrays at some point?
All languages have arrays or a method of carrying out the same procedure. But in python you could consider the
list
as python's array. However there is
numpy.array which can be used for
large amount of data.
Okay, thanks. So far it's been fascinating learning this new language.
You can use lists as arrays, but they are actually much more than that. For one thing, they can hold objects of different data types in a single list. The important thing to remember is that their members are full-fledged objects, not just variables.
And of course, that implies all the overhead and slow performance that its flexibility implies. As metulburr says, if you want real high-performing arrays, numpy is the way to go.
(Apr-21-2017, 02:21 AM)llanitedave Wrote: [ -> ]You can use lists as arrays, but they are actually much more than that. For one thing, they can hold objects of different data types in a single list. The important thing to remember is that their members are full-fledged objects, not just variables.
And of course, that implies all the overhead and slow performance that its flexibility implies. As metulburr says, if you want real high-performing arrays, numpy is the way to go.
Thanks. I appreciate your taking the time to explain that. I'm looking forward to becoming skilled in Python. I want to re-write some utilities that I wrote in VB years ago and this time be able to have both Windows and Linux versions of them. I'm working my way through the Eric Matthes book on Python. Seems to be pretty well written. I'll keep learning and getting better.
I'm grateful for everyone's help.
Unlike arrays in the most of the languages, a list in Python can hold arbitrary data types or objects.
(Apr-21-2017, 12:12 AM)metulburr Wrote: [ -> ]However there is numpy.array which can be used for large amount of data.
There is also simply (seldom used)
array, which is more or less in style of C arrays - with limitation to numeric types only.