[Numpy-discussion] What is .T?

Robert Kern robert.kern@gmail....
Tue May 6 14:28:24 CDT 2008


On Tue, May 6, 2008 at 2:22 PM, Keith Goodman <kwgoodman@gmail.com> wrote:
> What is .T? It looks like an attribute, behaves like a method, and
>  smells like magic. I'd like to add it to my class but don't no where
>  to begin.

It is a property. It returns the transpose of the array. If you had a
.transpose() method on your class already, you could do (in Python
2.4+)

  @property
  def T(self):
      return self.transpose()

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco


More information about the Numpy-discussion mailing list