View Python Numeric Values

Why Do I See Properties When I Display a Number?

MATLAB® displays all Python® types as objects, including a list of properties of the object.

py.int(5)
ans = 

  Python int with properties:

    denominator: 1
           imag: 0
      numerator: 5
           real: 5

    5

MATLAB displays the expected output value (5) on the last line.

What Is the L Character Attached to a Number?

Python appends an L character to the representation (display) of a long data type. For example, using Python version 2.7, type:

py.repr(py.long(5))
ans = 

  Python str with no properties.

    5L

MATLAB displays Python str and appends L for any Python function that uses the repr function to display its output.

You treat a long data type like any numeric type. For example, add two numbers:

py.long(5) + py.long(2)
ans = 

  Python long with properties:

    denominator: [1x1 py.long]
           imag: [1x1 py.long]
      numerator: [1x1 py.long]
           real: [1x1 py.long]

    7

The answer is the number 7.

Was this topic helpful?