Friday Finking: initialising values and implied tuples

Marco Ippolito maroloccio at gmail.com
Fri Apr 2 18:25:07 EDT 2021


> (a) basic linear presentation:
> 
> resource = "Oil"
> time = 1
> crude = 2
> residue = 3
> my_list = "long"
> 
> (b) using explicit tuples:
> 
> ( resource, time, crude, residue, my_list ) = ( "Oil", 1, 2, 3, "long" )
> 
> (c) linear and indented tuples:
> 
> (
>     resource,
>     time,
>     crude,
>     residue,
>     my_list
> ) = (
>     "Oil",
>     1,
>     2,
>     3,
>     "long"
> )

Choose: (a).

In (b) I have a problem matching identifiers to values horizontally at a
glance and in (c) I have the same problem vertically: i.e. "is 3 the value for
residue or crude above/to-the-left?"

Cognitive burden slows down and fatigues.

Alternatively, if the data "fits together", use a `namedtuple` with kwarg
initialisation or structured data types like `dataclasses`.


More information about the Python-list mailing list