GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • 
  • Consortium for Python Data API Standards
  • API specification
  • Array object
  • Purpose and scope
  • Terms and Definitions
  • Use cases
  • Assumptions
  • Design topics & constraints
  • Future API standard evolution
  • Broadcasting
  • Constants
  • Creation Functions
  • Data Type Functions

This view

  • Original page
  • New address

GeezerVison is showing data-apis.org — __getitem__ — Python array API standard DRAFT documentation

__getitem__¶

array.__getitem__(key: int | slice | ellipsis | None | Tuple[int | slice | ellipsis | array | None, ...] | array, /) → array¶

Returns self[key].

Parameters:
  • self (array) – array instance.

  • key (Union[int, slice, ellipsis, None, Tuple[Union[int, slice, ellipsis, array, None], ...], array]) – index key.

Returns:

out (array) – an array containing the accessed value(s). The returned array must have the same data type as self.

Notes

  • See Indexing for details on supported indexing semantics.

  • When __getitem__ is defined on an object, Python will automatically define iteration (i.e., the behavior from iter(x)) as x[0], x[1], …, x[N-1]. This can also be implemented directly by defining __iter__. Therefore, for a one-dimensional array x, iteration should produce a sequence of zero-dimensional arrays x[0], x[1], …, x[N-1], where N is the number of elements in the array. Iteration behavior for arrays having zero dimensions or more than one dimension is unspecified and thus implementation-defined.

    Note

    When key contains integer arrays on a device different from the device of self, the behavior is unspecified and thus implementation-defined.

Changed in version 2024.12: Clarified that iteration is defined for one-dimensional arrays.

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.