News for hackers. Stuff that matters.
Re:Records: Python library for making raw SQL queries to Pos... by nvader on Sunday February 07, 2016 @02:19PM (#11054299)
One argument I've seen for using dictionaries is that namedtuples restrict you to column names that are valid Python identifiers, which is a smaller set than postgres allows for column names (postgres allows the '$' and non-Latin characters).
Re:Records: Python library for making raw SQL queries to Pos... by hobarrera on Sunday February 07, 2016 @02:36PM (#11054390)
So does python:

>>> d = {'ñanáöß$': 1} >>> d {'ñanáöß$': 1} >>> d.keys() dict_keys(['ñanáöß$']) >>>

Re:Records: Python library for making raw SQL queries to Pos... by kilink on Sunday February 07, 2016 @02:44PM (#11054435)
The parent was talking about namedtuple.

    >>> collections.namedtuple("test", "$")
    Traceback (most recent call last):
    ...
    ValueError: Type names and field names can only contain alphanumeric characters and underscores: '$'
Re:Records: Python library for making raw SQL queries to Pos... by hobarrera on Sunday February 07, 2016 @08:02PM (#11055858)
That's because attribute names can't be called "$", so `sometuple.$` would be a syntax violation.
Re:Records: Python library for making raw SQL queries to Pos... by EmanueleAina on Tuesday February 09, 2016 @06:53AM (#11064678)
I guess everyone is aware of that, thanks,

The parent comments were discussing why choosing dicts over namedtuples for db-originated columns, and the fact that field names are restricted on namedtuples but not on dicts is a very compelling point.

Making examples usind dicts and explaining why namedtuples have restrictions is completely missing the point.

Re:Records: Python library for making raw SQL queries to Pos... by pyre on Sunday February 07, 2016 @03:11PM (#11054569)
HN supports "<pre><code>" blocks in a similar manor to Markdown, but using a two-space prefix (rather than Markdown's 4-space prefix):

  >>> d = {'ñanáöß$': 1}
  d {'ñanáöß$': 1}
  >>> d.keys()
  dict_keys(['ñanáöß$'])