this is my first question on stackoverflow. I just learnt the namedtuple and found sth weird.
When you want to initiate a namedtuple from an iterable, you have to either add a prefix * or use the _make method.
for instance:
City=namedtuple('city',['name','country','population','coordinates'])
delhi_data = ('Delhi NCR', 'IN', 21.935, LatLong(28.613889, 77.208889))
delhi = City(*('Delhi NCR', 'IN', 21.935, LatLong(28.613889, 77.208889)))
But when you initiate a tuple, dict or even orderedDict from the same collection package, you can just tuple() or dict() or orderedDict().
for instance:
from collections import OrderedDict
items = (
('A', 1),
('B', 2),
('C', 3)
)
regular_dict = dict(items)
ordered_dict = OrderedDict(items)
Why the syntax for namedtuple is so weird? Thanks!