4

When I create some class in python:

class Someclass():
   def __init__(self, some_arg):
       self.arg = some_arg

Then I create an instance of this class:

>>> some_instance = Someclass('something')

Then the output about our instance:

>>> some_instance
>>> <__main__.Someclass instance at 0x00000000021CA848>

Now I have few questions:

1) What does __main__ mean exactly in this example?

2) What does **at 0x00000000021CA848** mean, and what do I need this information for?

1
  • 2
    You need this information for debugging. When two variables, when printed, show the same address (hex number), you can assume they reference the same instance. Commented Nov 16, 2013 at 13:44

1 Answer 1

5

__main__ is the module's name and 0x00000000021CA848 is the address of the object in memory, if you are using CPython.

Its the string representation of your object. You can use it for debugging.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.