3 ms·
Using a list or tuple for the fields is generally best: Point = namedtuple('Point', ('x', 'y')) Support for a space and/or comma separated strings was req
by raymondh 5y ago
Using a list or tuple for the fields is generally best:
Point = namedtuple('Point', ('x', 'y'))
Support for a space and/or comma separated strings was requested by users. It made life easier for them when syncing with other space/comma separated strings. For example, an SQL query, "SELECT name, rank, serial_number FROM Soldiers;" would have a corresponding named tuple where the field names could be cut-and-pasted from the SQL query.
Soldier = namedtuple('Soldier', 'name, rank, serial_number')