do_slot{,_assign}

Issue #275 resolved
Antony Lee created an issue

Quick suggestion: provide a proxy slots attribute on Sexp objects such that one can use obj.slots.foo and obj.slots.foo = bar instead of obj.do_slot("foo") and obj.do_slot_assign("foo", bar).

Comments (5)

  1. Laurent Gautier

    That's a good idea.

    However, this would require a name conversion rule (e.g., converter . into _). One more robust than the simple one currently used (see issue #274).

    The alternative would be to have the proxy implement __getitem__ which would allow this:

    obj.slots['foo'] = bar
    
    obj.slots['r.likes.dots'] = foo
    
  2. Laurent Gautier

    I am bumping this to 2.7.x. R is essentially in a pass-by-value system while Python is pass-by-reference.

    I'd like a bit of time to try things out before having it in a release (while I'd like to release 2.6.0 now).

  3. Laurent Gautier

    An attribute slots acting as a mapping is implemented in revision 5790a6a26a90

    from rpy2 import robjects
    l = robjects.r('list(a=1, b=2, c=3)')
    # get the R attribute "names"
    l.slots['names']
    
  4. Log in to comment