Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python SQLAlchemy Basics Introduction to SQLAlchemy Querying

Andras Andras
Andras Andras
7,941 Points

Visual Studio Code return memory labels rather then actual lists

Visual Studio Code return memory labels rather then actual lists

(This returns through out the full tutorial series, every example not just here)

model.session.query(model.User).all()
[<model.User object at 0x000001DC06D8F7C0>, <model.User object at 0x000001DC06D8E110>, <model.User object at 0x000001DC06D8EBF0>, <model.User object at 0x000001DC06D8ED10>, <model.User object at 0x000001DC06D8E290>, <model.User object at 0x000001DC06D8F850>, <model.User object at 0x000001DC06D8D810>]

1 Answer

In the User class, try adding a __repr__ method specifying how to display the data.

def __repr__(self):
    return f"{self.title} by {self.author}"