Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (12.7k points)

According to this link:

Like most languages, Python has the concept of private elements:

Private functions, which can't be called from outside their module

If I try to define two files:

#a.py

__num=1

and:

#b.py

import a

print a.__num

At the point when I run b.py, it prints out 1 without giving any exemption. Is diveintopython wrong, or did I misjudge something? Furthermore, is there some approach to do characterize a module's capacity/function as private?

1 Answer

0 votes
by (26.4k points)

In Python, "Privacy" relies upon "consenting adults'" levels of understanding - you can't drive it (anything else than you can, all things considered;- ). A solitary driving underscore implies shouldn't get to it "from an external perspective" - two driving underscores (w/o following underscores) convey the message significantly more strongly

In any case, eventually, it actually relies upon social show and agreement: Python's contemplation is powerful enough that you can't cuff each and every software engineer on the planet to regard your desires.

Interested to learn the concepts of Python in detail? Come and join the python course to gain more knowledge in Python

Watch this video tutorial, if you want to gain more information

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...