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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T04:05:38+00:00 2026-06-19T04:05:38+00:00

I have a class that contains several functions(most of it contains code that parses

  • 0

I have a class that contains several functions(most of it contains code that parses smth., get all necessary info and print it). I’m trying to print a class but i get smth. like <_main_.TestClass instance at 0x0000000003650888>. Code sample:

from lxml import html
import urllib2
url = 'someurl.com'


class TestClass:

    def testFun(self):
        f = urllib2.urlopen(url).read()
        #some code

        print 'Value for ' +url+ ':', SomeVariable

    def testFun2(self):
        f2 = urllib2.urlopen(url).read()
        #some code

        print 'Value2 for ' +url+ ':', SomeVariable2

test = TestClass()
print test

When i print functions out of class – all is ok. What i’m doing wrong and how can I print a class?

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-19T04:05:38+00:00Added an answer on June 19, 2026 at 4:05 am

    That’s the expected behaviour. Python can’t know how the class is represented unless you define a __str__ or __repr__ method to give the class a string representation.

    To be clear: __repr__ is usually defined to produce a string that can be evaluated back into a similar object (in your case, TestClass()). The default __repr__ prints out the <__main__.TestClass instance at 0xdeadbeef> thing you see.

    Example __repr__:

    def __repr__(self):
        return self.__class__.__name__ + '()' # put constructor arguments in the ()
    

    __str__ can be defined to produce a human-readable “description” of the class. If not supplied, you get __repr__.

    Example __str__:

    def __str__(self):
        return "(TestClass instance)"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that contains a private typedef and several member functions: class
Hi I have a page that contains several different forms all of which are
I have a class with several functions that can render images. // render.php class
I have a class that contains this class method: def self.get_event_record(row, participant) event =
I have a class that contains data from some model. This class has metadata
I have a class that contains decoded video frames. I would like my decoder
I have this class that contains vars for db connection; Imports Microsoft.VisualBasic Imports System.Data.SqlClient
I have a class that contains a boolean field like this one: public class
I have a class that contains two sets. They both contain the same key
I have a class that contains objects of two other classes. I need one

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.