Tuples of tuples

17 views
Skip to first unread message

Harlan Gilbert

unread,
Mar 21, 2025, 8:32:39 AMMar 21
to Glowscript Users
Tuples of tuples do not seem to maintain their structure properly.  For example, in this program:

Web VPython 3.2
pairs = (("First", "1st"), ("Second","2nd"))
print(len(pairs), "entries")
for x in pairs:
    print(x)

The output should be
2 entries
('First', '1st')
('Second', '2nd')

but it prints
4 entries
First
1st
Second
2nd

The inner structure seems to have dissolved away.

This only arises with tuples of tuples.
Lists of tuples,  lists of lists, and tuples of lists all keep the internal structure:
pairs = [  ("First", "1st"), ("Second","2nd")  ]         #Behaves properly

Harlan

Don Grimshaw

unread,
Mar 22, 2025, 7:00:34 AMMar 22
to glowscri...@googlegroups.com
Interesting, I’ve only ever really used lists of lists (to mimic a matrix set up in glowscript) and yes that works fine .

--

---
You received this message because you are subscribed to the Google Groups "Glowscript Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glowscript-use...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/glowscript-users/eedc8987-cc26-4a4a-93e8-6868ffb565bdn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages