pauli_word_to_string(pauli_word, wire_map=None)[source]

Convert a Pauli word to a string.

A Pauli word can be either:

  • A single pauli operator (see PauliX for an example).

  • A Tensor instance containing Pauli operators.

  • A Prod instance containing Pauli operators.

  • A SProd instance containing a Pauli operator.

  • A Hamiltonian instance with only one term.

Given a Pauli in observable form, convert it into string of characters from ['I', 'X', 'Y', 'Z']. This representation is required for functions such as PauliRot.


This method ignores any potential coefficient multiplying the Pauli word:

>>> qml.pauli.pauli_word_to_string(3 * qml.PauliX(0) @ qml.PauliY(1))


This method assumes all Pauli operators are acting on different wires, ignoring any extra operators:

>>> qml.pauli.pauli_word_to_string(qml.PauliX(0) @ qml.PauliY(0) @ qml.PauliY(0))
  • pauli_word (Observable) – an observable, either a Tensor instance or single-qubit observable representing a Pauli group element.

  • wire_map (dict[Union[str, int], int]) – dictionary containing all wire labels used in the Pauli word as keys, and unique integer labels as their values


The string representation of the observable in terms of 'I', 'X', 'Y', and/or 'Z'.

Return type



TypeError – if the input observable is not a proper Pauli word.


>>> wire_map = {'a' : 0, 'b' : 1, 'c' : 2}
>>> pauli_word = qml.PauliX('a') @ qml.PauliY('c')
>>> pauli_word_to_string(pauli_word, wire_map=wire_map)