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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:10:04+00:00 2026-05-15T00:10:04+00:00

in python tutorial added that python cannot hide its attributes from other classes. some

  • 0

in python tutorial added that python cannot hide its attributes from other classes. some thing such as private data in C++ or java..But also i know that we can use _ or __ to set some variables as privated one but it is not enogh. I think it is a weak if it is not any thing to do it.

  • 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-15T00:10:04+00:00Added an answer on May 15, 2026 at 12:10 am

    This is part of Python’s philosophy. It basically trusts you to be sensible and exercise caution with anything that starts with an underscore. If you really want to hide state so no one can touch it, you can do this:

    def fort_knox():
        # A very private variable
        gold = [0]
    
        class impl(object):
            def add_gold(self, amt):
                gold[0] += amt
    
            def remove_gold(self, amt):
                raise Exception('No withdrawals!')
    
            def count_gold(self):
                return gold[0]
    
        return impl()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the python keyword with used for? Example from: http://docs.python.org/tutorial/inputoutput.html >>> with open('/tmp/workfile',
I've got zero experience with Python. I have looked around some tutorial materials, but
I noticed that in the AllegroGraph Python API tutorial here , whenever they want
Official Python tutorial states that Unicode strings in Python can be used like this:
I'm trying to emulate the following output (from Marakana.com's excellent Python tutorial : >>>
I was learning python using the tutorial that comes with the standard python installation.
The following sentences are a cause of confusion for me(from Guido's Tutorial on python.org):
I am following the Python tutorial and at some point they talk about how
I'm following the python tutorial at their site and I'm currently at the break
I can't find any information on [::-1] . In the wikibooks python tutorial ,

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.