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

  • Home
  • SEARCH
  • 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 7689031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:04:13+00:00 2026-05-31T20:04:13+00:00

If I do: print The item is: + str(1) + . I will get:

  • 0

If I do:

    print "The item is:" + str(1) + "."

I will get:

    The item is 1.

But if I use an object of my class, dbref (here x is one of it), and try to stringify it:

    print "The item is:" + str(x) + "."

I will get:

    The item is <mufdatatypes.dbref instance at 0xb74a2bec>.

I’d rather it return a string of my own design. Is there a function I can define within my class that will let me do this?

  • 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-31T20:04:14+00:00Added an answer on May 31, 2026 at 8:04 pm

    Return a string from the __str__() method. Like so:

    class SomeClass(object):
    
      def __init__(self, value):
        self.value = value
    
      def __str__(self):
        return '<SomeClass %s>' % self.value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to use amazon API using PHP. If I use print_r($parsed_xml->Items->Item->ItemAttributes) it show
void print(part *item, int part_count) { int i=0; for (i=0; i<part_count; i++) { printf(Item
print_r($address['Country']); echo $address['Country']['name']; Here is what I get for the print_r: Array ( [Country]
I am trying to add together two lists so the first item of one
i would like to append an item into list_b only if it is one
>>> s = 'auszuschließen' >>> print(s.encode('ascii', errors='xmlcharrefreplace')) b'auszuschlie&#223;en' >>> print(str(s.encode('ascii', errors='xmlcharrefreplace'), 'ascii')) auszuschlie&#223;en Is
list1 = [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z] for item in list1: print item Not sure why the above
Im not sure what to look for to try to achieve this but I
I currently have implemented an overlay item that shows an icon for Geo-point on
Print all 12 verses of the popular holiday song . By 12 verses I

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.