News for hackers. Stuff that matters.
Re:W3schools.dev Redirects to Mozilla Developer Network by scrollaway on Friday March 01, 2019 @10:08AM (#19281262)
"Array" is a pretty loosely defined term that varies from language to language. Python lists are what you may know as "variable-length arrays" of python objects (in other words: not type constrained). If you want type-constrained arrays, you'll use the array module: https://docs.python.org/3/library/array.html

that w3schools page is indeed nonsense. They should probably stick to JS.

Re:W3schools.dev Redirects to Mozilla Developer Network by geoelectric on Friday March 01, 2019 @01:20PM (#19283742)
It depends on how strictly one defines "array." If you mean it generically as "an indexable contiguous memory buffer containing the actual data being indexed," pretty sure Python lists don't comply even at a mechanical level.

While the Python 3 docs for arrays certainly do lean on the type-constraint, I notice it also has the various operations that imply a contiguous buffer (cast to bytes, etc.), so I wonder if that's not the real distinction and the type constraint serves that.

Traditional Python lists are much closer to what I know as a vector: indexable like an array, but dynamically expandable and usually implemented as a list of references to data structures instead of containing the data itself so allows for heterogenous data.

Informally, I've certainly called both types of things arrays, right or wrong, and rarely call anything a vector other than container classes by that name, but I do suspect that's what your parent comment is drilling on.

* Then there's the JS Array class, which acts more like a vector than array by those definitions, so who knows.

Re:W3schools.dev Redirects to Mozilla Developer Network by umanwizard on Friday March 01, 2019 @10:13AM (#19281310)
Python lists may well be implemented as arrays. I don't know if they are or not, as I haven't read the Python interpreter source code.

If they are, then the article is even worse, as the disclaimer that Python doesn't have arrays is a lie!

Re:W3schools.dev Redirects to Mozilla Developer Network by cferr on Friday March 01, 2019 @03:06PM (#19284752)
Everything in Python is implemented as a dict behind the scenes, which is implemented in C with a few different types. Python does have arrays in the standard library's array module, so yes saying python doesn't have arrays would be a lie.