[Python-3000] Ordered mapping type for Python 3000? (original) (raw)
Josiah Carlson jcarlson at uci.edu
Wed Mar 28 17:33:08 CEST 2007
- Previous message: [Python-3000] Ordered mapping type for Python 3000?
- Next message: [Python-3000] The latest extended buffer PEP
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"BJörn Lindqvist" <bjourne at gmail.com> wrote:
On 3/28/07, Josiah Carlson <jcarlson at uci.edu> wrote: > > "BJörn Lindqvist" <bjourne at gmail.com> wrote: > > el = makeel('input', type = 'text', class = 'query') > > XML elements are not ordering sensitive. Except when you write them. If you want the output to be exactly you must have an order.
I've not come across a case where web browsers or other XML consumers have cared about those kinds of orderings (except in testing cases). And those cases where order has mattered, sorting by name (so as to consistantly produce as in your example) gets one a consistant ordering in all Pythons.
> > col = attrtuple(r = 255, g = 0, b = 128) > > r, g, b = col > > That is handled reasonably well with Raymond's recipe (or variants > thereof).
Well, no. NamedTuple('Color', 'r g b')(r = 255, g = 0, b = 128) is not at all the same thing. > > Or interface easier with tabular, order-dependent data. > > That is handled with the ordered dictionary and metaclass sytax PEP. Yes. Making **kwargs orderable would merely be the syntactic support that would make ordered dictionaries a breeze to work with.
That is not what I meant. For data defined as columns, etc., where order matters (also in the case of NamedTuple), PEP 3115 handles this case fairly well, generally like:
class Color(NamedTuple):
r = g = b = None
a = Color(r = 255, g = 0, b = 128)
or
class Contacts(TypedNameTuple):
firstname = text
middle = text
lastname = text
...
Yes, you need to take the time to create the prototype. But if taking the time to create one prototype earlier in the source to define ordering isn't reasonable, then it seems to me that one is trying to be too clever. Also, I find Color(r = 255, g = 0, b = 128) to be clearer than ordered_mapping(r = 255, g = 0, b = 128) .
I would also point out that neither the OP (nor anyone else) has proposed a possible implementation (or strategy for that matter).
- Josiah
- Previous message: [Python-3000] Ordered mapping type for Python 3000?
- Next message: [Python-3000] The latest extended buffer PEP
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]