Friday Finking: initialising values and implied tuples

Rob Cliffe rob.cliffe at btinternet.com
Sat Apr 3 08:00:25 EDT 2021



On 03/04/2021 04:09, 2QdxY4RzWzUUiLuE at potatochowder.com wrote:
> On 2021-04-03 at 02:41:59 +0100,
> Rob Cliffe via Python-list <python-list at python.org> wrote:
>
>>      x1 = 42; y1 =  3;  z1 = 10
>>      x2 = 41; y2 = 12; z2 = 9
>>      x3 =  8;  y3 =  8;  z3 = 10
>> (please imagine it's in a fixed font with everything neatly vertically
>> aligned).
>> This has see-at-a-glance STRUCTURE: the letters are aligned vertically
>> and the "subscripts" horizontally.  Write it as 9 lines and it becomes
>> an amorphous mess in which mistakes are harder to spot.
> I agree that writing it as 9 lines is an accident waiting to happen, but
> if you must see that structure, then go all in:
>
>      (x1, y1, z1) = (43,  3, 10)
>      (x2, y2, z2) = (41, 12,  9)
>      (x3, y3, z3) = ( 8,  8, 10)
Agreed, that is even easier to read.  (It would be kinda nice if the 
compiler could optimise the tuples away, for those of us who are 
paranoid about performance.)
>
> Or even:
>
>      ((x1, y1, z1)
>       (x2, y2, z2)
>       (x3, y3, z3)) = ((43,  3, 10)
>                        (41, 12,  9)
>                        ( 8,  8, 10))
>
> Or not.  YMMV.  I guess this doesn't come up enough in my own code to
> worry about it.



More information about the Python-list mailing list