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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:22:31+00:00 2026-06-12T13:22:31+00:00

I am going through the code of threading module( <Python Home>/lib/threading.py ) on Active

  • 0

I am going through the code of threading module(<Python Home>/lib/threading.py) on Active python 2.7.2 32 bit for Windows. In the __init__ function of the class Thread, there are many variables defined:

self.__target = target
self.__name = str(name or _newname())
self.__args = args
self.__kwargs = kwargs
self.__daemonic = self._set_daemon()
self.__ident = None
self.__started = Event()
self.__stopped = False
self.__block = Condition(Lock())
self.__initialized = True

Here is how I am calling the __init__ function of class Thread:-

class ThreadWithReturnValue(Thread):
    def __init__(self, group=None, target=None, name=None,
                 args=(), kwargs={}, Verbose=None):

        Thread.__init__(self, group, target, name, args, kwargs, Verbose)
        self._return = None
        print 'in init: ', self._Thread__target

I fail to understand that the variable self._Thread__target is not initialised anywhere in the __init__ function of class Thread. But, if I print this variable in my own __init__ function, the actual value for self.__target from class Thread‘s __init__ function is shown.

Also, I tried to edit the threading module and put this line as the last line of the __init__ function of class Thread:-

print 'in init of Thread class in threading: ', self._Thread__target

Still, I could see the value being printed and the interpreter does not display me any errors. So, I tried to find any function which might be doing the renaming stuff. But, could not find it.

This is happening with all the other variables defined in the __init__ function of class Thread. I want to know how the variables like self.__target are getting renamed to self._Thread__target.

  • 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-12T13:22:32+00:00Added an answer on June 12, 2026 at 1:22 pm

    this is called name mangling it is what happens every time a variable starts with a __

    see : http://docs.python.org/release/1.5/tut/node67.html and http://docs.python.org/reference/expressions.html#atom-identifiers

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

Sidebar

Related Questions

While I'm going through Python code and seeing functions called, I notice things like
I'm going through a Fortran code, and one bit has me a little puzzled.
after going through glibc code for malloc() and the actual allocator i.e _int_malloc() function
I was going through some code and I saw this: public class A {
While going through the code of an application, i came across the putpwent() function
I am going through some code and at the beginning of the script we
i am going through the code for xml parser, and i found this code,
I was going through some code that I downloaded off the internet ( Got
So I'm going through old code (2.0) and I came across this: object isReviewingValue
I am going through my project code base, which consits of libraries and applications.

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.