-2

After quite some effort, I'm still unable to find any clue about the meaning of the @ character in python syntax, such as in the (provided to me) function

def PI(pi0,P=P,T=T):
# Function PI computes the state probability vectors
# of the Markov chain until time T

    pi_ = array([pi0])
    for i in range(T):
        pi_ = vstack((pi_,pi_[-1] @ P))

    return pi_

(where pylab has been previously imported). At parsing, this character rises a SyntaxError message.Any clue welcome !

bla
  • 1,684
  • 1
  • 13
  • 17
  • 4
    [The operator](http://legacy.python.org/dev/peps/pep-0465/) was added in Python 3.5; you need to be using at least that version for it to parse. It’s an operator not implemented by any built-in Python type, so if you need more details you’ll have to specify what `pi_[-1]` is. – Ry- Feb 22 '18 at 01:10
  • 1
    That would be the [matrix multiplication operator](https://docs.python.org/3.6/library/operator.html#operator.__matmul__). It was added in Python 3.5. – Christian Dean Feb 22 '18 at 01:10
  • What object from the pylab library is `pi_`? – Christian Dean Feb 22 '18 at 01:16
  • link to answer from the original Q&A link: https://stackoverflow.com/questions/6392739/what-does-the-at-symbol-do-in-python/28997112#28997112 – Jean-François Fabre Feb 22 '18 at 01:23

1 Answers1

0

The name of the operator being used is the matrix multiplication operator. Here is the description of the operator from the documentation:

Return a @ b.

New in version 3.5.

As you can see, it was first added in Python 3.5. Thus, if your getting a SyntaxError, you're likely using Python version 3.4 or lower.

Community
  • 1
  • 1
Christian Dean
  • 19,561
  • 6
  • 42
  • 71