Late-binding of function defaults (was Re: What is a function parameter =[] for?)

Marko Rauhamaa marko at pacujo.net
Wed Nov 25 08:53:01 EST 2015


BartC <bc at freeuk.com>:

> Using tuples in the same way that other languages implement records is
> going to be difficult if you can't change the values of the fields!

Guido could decide tomorrow that tuples are mutable. The decision is
more or less arbitrary, and has to do with dictionary keys, I bet (not a
particularly good reason).

Anyway, Python has two ways to represent records: classes and tuples.
Tuples are nice because they are concise and ad hoc. Often you start
with a scalar value, then turn it into a tuple. After a while your handy
tuple turns out a bit cumbersome to use so you convert it into an actual
class.


Marko



More information about the Python-list mailing list