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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:27:49+00:00 2026-06-08T12:27:49+00:00

I have a dictionary of objects like so {‘name1′:oject_instance_1,’name2′:oject_instance_2,’name3’:oject_instance_3} In my class definition of

  • 0

I have a dictionary of objects like so
{'name1':oject_instance_1,'name2':oject_instance_2,'name3':oject_instance_3}
In my class definition of object, I have defined both the __str__() method and the __repr__() method as follows:

def __str__(self):
    return('{0} pathway containing {1} genes, with a total sequence length of {2}'.format(self.id, len(self.genes), self.length))

def __repr(self):
    return self.__str__    

In case it’s important self.id is a string, self.genes is a list, and self.length is an int

The problem is when I go to print this dictionary I get:

{'pid1003': <Pathway.Pathway instance at 0x10169d680>, 'pid1002': <Pathway.Pathway instance at 0x10169d638>, 'pid1001': <Pathway.Pathway instance at 0x10169d5f0>}

but printing in a loop like

for v in dict.values():
    print(v)

works fine.

Any ideas why?
Thanks!

  • 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-06-08T12:27:50+00:00Added an answer on June 8, 2026 at 12:27 pm

    Maybe you should implement __repr__, not __repr.

    Edit:

    And __repr__ should return a String, not a function. So, as noted in the comments, return str(self).

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

Sidebar

Related Questions

I have defined a class Listener and created a dictionary of Listener objects. Each
I have a dictionary with embedded objects, which looks something like this: notes =
I have a class that has an internal list of other objects like so:
Say I have 3 Dictionary<string, string> objects. All 3 have the same key like
I have a global dictionary with Class objects and NSString keys. Every custom subclass
I have a Dictionary of Dictionarys of Array of Objects. Just like this: A
Assuming I have some objects like this: Class NetworkSwitch { private String _name; String
I have a dictionary object which i would like to encrypt, then put it
all: I have 2 Dictionary objects d1 and d2. They are created separately at
I have a dictionary of objects; they are all POCO objects that should be

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.