Closed Thread
Results 1 to 3 of 3

Thread: What the heck is private data in python ?

  1. #1
    Join Date
    Feb 2010
    Location
    Istanbul , Turkey
    Posts
    9
    Rep Power
    0

    What the heck is private data in python ?

    Hi guys ,

    I am a C++ and Java programmer and i just started learning Python . It seemed that it has a very simple syntax , it is powerful actually but there is something that i havent been able to comprehend . We know that we can make an instance private member by adding "__" at the beginning . However as i just discovered any private data can be reached just by calling it _ClassName__MemberName . So what is the goal of using private data ? Thanks for replies .

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2009
    Location
    Santa Clarita, CA
    Posts
    2,111
    Blog Entries
    47
    Rep Power
    31

    Re: What the heck is private data in python ?

    Python sees private data differently. Variables are private by convention, not by force, it should be assumed by you if you distribute Python code that your users will keep the data private for the sake of not using your objects internals, but forcing the issue makes it so the few times a programmer who knows what he's doing when it could potentially be helpful is more damaging than helpful.

    Simply put, a truly "private" variable does not exist in Python, instead you have variables that are private by convention. This is one of many ways Python does things differently.
    Wow I changed my sig!

  4. #3
    Join Date
    Feb 2010
    Location
    Istanbul , Turkey
    Posts
    9
    Rep Power
    0

    Re: What the heck is private data in python ?

    thx zeke i guess it's one of the weird things in python for non python programmers .

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. DLL Heck
    By PGP_Protector in forum C# Programming
    Replies: 6
    Last Post: 05-28-2010, 10:47 AM
  2. Passing string from one private sub to another private sub
    By terrylau in forum Visual Basic Programming
    Replies: 1
    Last Post: 07-10-2009, 05:24 AM
  3. Accessing private data member
    By boredaxel in forum C and C++
    Replies: 6
    Last Post: 02-23-2009, 10:46 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts