Myrmornis 10 months ago

You should use a tuple there: it's a collection of fixed size where each slot has an identity. (There's a common confusion in Python circles that the main point of tuples is immutability; that's not so).

ghxst 10 months ago

Why would you do this over `return key, value` which produces a tuple? Just curious.

  • dgan 10 months ago

    Not the parent, but i return heterogeneous lists of the same length to the excel to be used by xlwings. The first row being the headers, but every row below is obviously heterogeneous

  • slightwinder 10 months ago

    To quote the Zen of Python:

        Explicit is better than implicit.
        Readability counts.
    • ErikBjare 10 months ago

      How does that apply in this case?

      • slightwinder 10 months ago

        "return key, value" is implicit. While "return [key, value]" is explicitly telling the full return-value. And it's (for me) more readable than "return (key, value)".