Macaulay2 » Documentation
Packages » Python » PythonObject » PythonObject _ Thing
next | previous | forward | backward | up | index | toc

PythonObject _ Thing -- get elements of python sequences

Description

You may access elements of python sequences using _. This is equivalent to square brackets ([]) in Python. For example, this works for lists.

i1 : x = toPython {1, 2, 3, 4}

o1 = [1, 2, 3, 4]

o1 : PythonObject of class list
i2 : x_1

o2 = 2

o2 : PythonObject of class int

It also works for dictionaries.

i3 : x = toPython hashTable {"spam" => 1, "eggs" => 2}

o3 = {'spam': 1, 'eggs': 2}

o3 : PythonObject of class dict
i4 : x_"eggs"

o4 = 2

o4 : PythonObject of class int

Ways to use this method:


The source of this document is in Python/doc/list.m2:27:0.