Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
C0D4669025yArrays are from C, and unless you absolutely need to use them, you would use a list.
Key difference is array can hold a single data type, where as list can hold any. -
@C0D4 yup, found that out later. I've used arrays (and understand them conceptually) in plenty other languages but never such thing in python.
I felt like an idiot. -
-
Puh...
Python Array and List can be two seperate or two similar things.
https://docs.python.org/3/library/...
Two different things....
However, most tutorials, eg W3C list arrays as lists...
https://w3schools.com/python/...
Module != Generic Type
The module is bound to a specific type, the generic type (as in most other languages) is not type specific, and exactly the same as a list.
Pretty fucked up questions imho -
@IntrusionCM yeah my thought exactly. It was asked by a program manager. The question went like this: "oh, you know python? What's the difference between an array and a list in python?"
Its such a trivial sounding question. I wouldn't be as bothered if it didn't sound so bad outside the context of python. I guarantee I left the impression on him that I didn't know a thing about python and lied on my resume. Oh well.
Just the idea of typing mattering to that extent pisses me off. Seems very un-pythonic. -
C0D4669025y@yellow-dog i think that's based on data type, or am I thinking tuples with lists 🤔
Where's the docs when you need them. -
@yellow-dog that's a tuple, not an array.
Arrays are for storing a large number of values of the same time (and only primitive types like int/float/character). They're more efficient than lists but far less versatile.
At least that's what Google tells me, as I've never used or needed to know anything about python arrays before. -
devbf2165yWhen we did numerical mathematics in Python, we always used arrays because they would hold only and exclusively float values.
Just got asked what the difference was between an array and a list in python in an interview for a devops position. Who tf uses arrays in python???? I didn't even know there was such thing.
rant