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 1085767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:43:48+00:00 2026-05-16T22:43:48+00:00

print OBJECT calls OBJECT.__str__() , then when OBJECT.__repr__() is called? I see that print

  • 0

print OBJECT calls OBJECT.__str__(), then when OBJECT.__repr__() is called? I see that print OBJECT calls OBJECT.__repr__() when OBJECT.__str__() doesn’t exist, but I expect that’s not the only way to call __repr__().

  • 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-16T22:43:49+00:00Added an answer on May 16, 2026 at 10:43 pm
    repr(obj)
    

    calls

    obj.__repr__
    

    the purpose of __repr__ is that it provides a ‘formal’ representation of the object that is supposed to be a expression that can be evaled to create the object. that is,

    obj == eval(repr(obj))
    

    should, but does not always in practice, yield True

    I was asked in the comments for an example of when obj != eval(repr(obj)).

    class BrokenRepr(object):
        def __repr__(self):
            return "not likely"
    

    here’s another one:

    >>> con = sqlite3.connect(':memory:')
    >>> repr(con)
    '<sqlite3.Connection object at 0xb773b520>'
    >>> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The __repr__ function of python is fancy as it is called when print OBJECT
Considering this is only for my homework I don't expect much help but I
I was given to understand that calling print obj would call obj.__str__() which would
class HelloWorld(object): def say_it(self): return 'Hello I am Hello World' def i_call_hello_world(hw_obj): print 'here...
How can I print any object into system clipboard just like printfn %A does?
When you are going to print an object, a friend operator<< is used. Can
Why I have to use Object[] to print the list if I select specific
ive got an object that looks like this with print_r(): SimpleDOM Object ( [0]
How to print the reverse of the String java is object orientated language without
How do I print the value stored in BIO object time. Basically I need

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.