Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6870995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:45:06+00:00 2026-05-27T03:45:06+00:00

The SQLAlchemy ORM tutorial uses this class: >>> from sqlalchemy import Column, Integer, String

  • 0

The SQLAlchemy ORM tutorial uses this class:

>>> from sqlalchemy import Column, Integer, String
>>> class User(Base):
...     __tablename__ = 'users'
...
...     id = Column(Integer, primary_key=True)
...     name = Column(String)
...     fullname = Column(String)
...     password = Column(String)
...
...     def __init__(self, name, fullname, password):
...         self.name = name
...         self.fullname = fullname
...         self.password = password
...
...     def __repr__(self):
...        return "<User('%s','%s', '%s')>" % (self.name, self.fullname, self.password)

Why would you go to all the trouble of having a string that will work nicely when eval()‘d, only to break that functionality but surrounding it with angle brackets?

I realise that the eval(repr(foo)) idiom is far from the only purpose of __repr__, but it it still seems odd how it seems to deliberately be disabled here. Is there some greater logic to this that I’m missing, or is it just some arbitrary decision?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:45:07+00:00Added an answer on May 27, 2026 at 3:45 am

    Bear in mind that eval is not used too much; crafting strings for it (or checking if they really already work) is just unnecessary extra effort.
    Putting the angle brackets in without second thought is much easier, and doesn’t give people ideas about using eval (which is dangerous if you’re not careful).

    In other words, there was no deliberate decision to break eval(repr(x)) here. It’s just customary to put angle brackets around __repr__ output.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Code replicating the error: from sqlalchemy import create_engine, Table, Column, Integer from sqlalchemy.ext.declarative import
Here's my code: from sqlalchemy import create_engine, Column, Integer from sqlalchemy.ext.declarative import declarative_base from
Here's what I've got: from sqlalchemy import * from sqlalchemy.orm import * from web.models.card
Consider the following snippet of Python code: from sqlalchemy import * from sqlalchemy.orm import
I'm using the SQLAlchemy Python ORM in a Pylons project. I have a class
I have an SQLAlchemy ORM class, linked to MySQL, which works great at saving
Python noob here, Currently I'm working with SQLAlchemy, and I have this: from __init__
I have model class CreatedMixin(object): __abstract__ = True @declared_attr def created_by(cls): return Column(Integer, ForeignKey('user.user_id',
Consider the following Python script, which uses SQLAlchemy and the Python multiprocessing module. This
I'm using __init__() like this in some SQLAlchemy ORM classes that have many parameters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.