Skip to content

Object representation in Variable Explorer #310

@jpcanal

Description

@jpcanal

Problem Description

In the variable explorer, non-standard objects value is redundant with type. __str__ or __repr__ result would be expected to be seen, which usually carries useful information about the object.
Standard Python objects are cleared for representation visualization, but not any object (comment about this on spyder-ide/spyder#1867).
A performance issue is mentioned in the link, but I think PyCharm does show this representation for custom objects.

What steps reproduce the problem?

  1. Create custom object, for example:
class Vector:
    def __init__(self, x, y, z):
        self.x = x
        self.y = y
        self.z = z
    def __str__(self):
        return "Vector (x=%f, y=%f, z=%f)" % (self.x, self.y, self.z)

vect = Vector(1,2,3)
  1. See variable vect in Variable Explorer. Type is Vector and Value is Vector object of __main__ module.

What is the expected output? What do you see instead?

Value column is expected to be populated with Vector (x=1.000000, y=2.000000, z=3.000000) or similar information about the object, as print(obj) would show.

Versions

  • Spyder version: 5.1.1
  • Python version: 3.7.9 64 bits
  • Qt version: 5.12.10
  • PyQt version: 5.12.3
  • Operating System name/version: Windows 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions