1

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.

Comments
  • 2
    Arrays 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.
  • 1
    @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.
  • 0
    >the absolute state of python developers

    @C0D4 aint array immutable and list mutable?
  • 0
    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
  • 0
    @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.
  • 1
    @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.
  • 1
    @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.
  • 0
    When we did numerical mathematics in Python, we always used arrays because they would hold only and exclusively float values.
Add Comment