Raymond Hettinger added the comment: > but may be implementing access via attributes would > be even better? mo.groupnamespace().col or mo.ns.col?
The whole point is to eliminate the unnecessary extra level. Contrast using DOM with using ElementTree. The difference in usability and readability is huge. If you do much in the way of regex work, this will be a win: mo['name'], mo['rank'], mo['serialnumber'] There are several problems with trying to turn this into attribute access. One of the usual ones are the conflict between the user fieldnames and the actual methods and attributes of the objects (that is why named tuples have the irritating leading underscore for its own attributes and methods). The other problem is that it interferes with usability when the fieldname is stored in a variable. Contrast, "fieldname='rank'; print(mo[fieldname])" with "fieldname='rank'; print(getattr(mo, fieldname))". I'm happy to abandon the "len(mo)" suggestion, but mo[groupname] would be really nice. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24454> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com