Raymond Hettinger <[email protected]> added the comment:
+1 from me. We're already made regular expression match objects less opaque
and that has been useful. There's no need for a python-ideas discussion for
this.
If a repr doesn't round-trip, we generally put it angle brackets (see PEP 8):
>>> re.search(r'([a-z]+)(\d*)', 'alpha7')
<re.Match object; span=(0, 6), match='alpha7'>
The Row object access style uses square brackets and has a keys() method. That
suggests a dict-like representation would be intuitive and match how Row
objects are used: ro['salary'] and ro.keys().
Putting those two ideas together we get:
<sqlite3.Row object; {'name': 'John', 'salary': 42}>
Note the OP's suggestion for keyword argument style doesn't make sense for two
reasons: 1) Row objects don't allow attribute access (i.e. ro.name is invalid)
and 2) the field names are not required to be valid Python identifiers (i.e.
ro['class'] is possible but ro.class is syntactically invalid because "class"
is a keyword).
----------
nosy: +rhettinger
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue35889>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com