On Mon, Dec 20, 2010 at 3:27 PM, Luca Beltrame <luca.beltr...@unifi.it> wrote:
> Hello,
>
> As I'm working with R's lists and porting some code away from R to Python, I'd
> like to know if they can be replaced with a named vector (which is what a R
> list essentially is, to my untrained eye). For example:
>
> in R
>
> my.list <- list(a="some.value", b="another.value")
>
> in Python I would  use:
>
> my_list = robjects.StrVector(["some.value", "another.value"])
> my_list.names = ["a", "b"]
>
> Is this the right approach or is there a better way?
>

Depending on how you use the data structure, a Python dict
(dictionary - like a Perl hash) might work (but you lose the order).

As of Python 2.7, there is an ordered-dictionary class included
in the collections module - but I don't know if rpy2 supports it.

Peter

------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to