descriptors for container items

Discussion in 'Python' started by Brock Filer, Sep 2, 2005.

  1. Brock Filer

    Brock Filer Guest

    .... or something like that.

    I have an XMLish data structure whose nodes' __get/set/del item__
    methods resolve as:

    node['foo'] -> node.children['foo']
    node['@bar'] -> node.attributes['bar']

    so you can say:

    countries['us']['Colorado']['Denver']['@population']

    This is going to be used in user-input formulae, so I'm willing to do a
    lot of work for minor beautifications. I'd like to be able to say (I
    know, the quotes are still ugly, but at least you save a bracket):

    countries/'us'/'Colorado'/'Denver'/'@population'

    That's easy to do with a __div__ method, but it only works for getting,
    not setting or deleting.

    I'd appreciate any thoughts on this problem. I keep thinking
    descriptors might be involved somehow in the solution, but I may be on
    a completely wrong track.
    Brock Filer, Sep 2, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vivi Orunitia
    Replies:
    11
    Views:
    4,444
    Martijn Lievaart
    Feb 4, 2004
  2. Maitre Bart
    Replies:
    2
    Views:
    507
    Maitre Bart
    Feb 11, 2004
  3. Steven T. Hatton
    Replies:
    4
    Views:
    3,861
    Rob Williscroft
    Dec 5, 2004
  4. Brock Filer

    descriptors for container items

    Brock Filer, Sep 3, 2005, in forum: Python
    Replies:
    0
    Views:
    258
    Brock Filer
    Sep 3, 2005
  5. Brock Filer

    descriptors for container items

    Brock Filer, Sep 4, 2005, in forum: Python
    Replies:
    0
    Views:
    235
    Brock Filer
    Sep 4, 2005
Loading...

Share This Page