I found that in python we have no realy private attributes.we just can use _ or __.but these are not deny access to my attributes.some thing such as private variables in c++.
Is it TRUE? Realy python is week in these?
funfullson
0
Junior Poster in Training
Recommended Answers
Jump to PostGo ahead and test it!
If you can't live with the amount of protection given, use C++.
Jump to PostIt is in fact true. Nothing is truly private in Python. What happens is that Python alters the name of the variable internally.
>>> class Foo: __privatebar = "HelloWorld!" >>> Foo.__privatebar Traceback (most recent call last): File "<pyshell#3>", line 1, in <module> Foo.__privatebar AttributeError: class Foo has …
Jump to PostDirect hardware access is not Python's great strength, but yes, it is possible using the
ctypes
module, or if you really want it your way, by providing a C or C++ extension.When I started as a C++ programmer coming from C, I thought that having private, protected and …
All 12 Replies
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
ultimatebuster
14
Posting Whiz in Training
sneekula
969
Nearly a Posting Maven
funfullson
0
Junior Poster in Training
griswolf
304
Veteran Poster
funfullson
0
Junior Poster in Training
griswolf
304
Veteran Poster
sneekula
969
Nearly a Posting Maven
griswolf
304
Veteran Poster
jcao219
18
Posting Pro in Training
griswolf
304
Veteran Poster
jcao219
18
Posting Pro in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.