Macaulay2 » Documentation
Packages » Python » PythonObject » delete(Thing,PythonObject)
next | previous | forward | backward | up | index | toc

# delete(Thing,PythonObject) -- delete elements from mutable python sequences

- Function: delete
- Usage:
    `delete(i, x)`
- Inputs:
  - i, a thing,
  - x, a python object,

## Description

This deletes the element of x indexed by i. This is equivalent to the `del` keyword in Python.

    i1 : x = toPython {3, 5, 7, 9}

    o1 = [3, 5, 7, 9]

    o1 : PythonObject of class list

    i2 : delete(0, x)

    i3 : x

    o3 = [5, 7, 9]

    o3 : PythonObject of class list

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

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

    o4 : PythonObject of class dict

    i5 : delete("eggs", x)

    i6 : x

    o6 = {'spam': 1}

    o6 : PythonObject of class dict

## Ways to use this method:

- delete(Thing,PythonObject) -- delete elements from mutable python sequences

The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/Python/doc/list.m2:78:0.