Friday, March 1, 2024

python doodle

"""
from collections import OrderedDict

d = OrderedDict([("b",1), ("a",2), ("c",3)])
print("ordered")
for k,v in d.items():
    print(k,v)
    
print("no order")
dat = {"b":1, "a":2, "c":3}
for k,v in dat.items():
    print(k,v)

#ordered
#('b', 1)
#('a', 2)
#('c', 3)
#no order
#('a', 2)
#('c', 3)
#('b', 1)

#inspired by
#https://stackoverflow.com/questions/41866911/ordereddict-isnt-ordered
"""

"""
from collections import namedtuple
V = namedtuple("V", ["a", "b", "c"])
v = V(a=1, b=2, c=3)
print(v.a, v.b, v.c)
#(1, 2, 3)
""" 
Happy Sketching!