Does python have ‘private’ variables in classes?

“In java, we have been taught about public/private/protected variables”

“Why is that not required in python?”

For the same reason it’s not required in Java.

You’re free to use — or not use private and protected.

As a Python and Java programmer, I’ve found that private and protected are very, very important design concepts. But as a practical matter, in tens of thousands of lines of Java and Python, I’ve never actually used private or protected.

Why not?

Here’s my question “protected from whom?”

Other programmers on my team? They have the source. What does protected mean when they can change it?

Other programmers on other teams? They work for the same company. They can — with a phone call — get the source.

Clients? It’s work-for-hire programming (generally). The clients (generally) own the code.

So, who — precisely — am I protecting it from?

Right. The schizophrenic sociopath who refused to read the API comment blocks.

Well said!! http://stackoverflow.com/a/1641305/2542750

Advertisements

Share your blooming thoughts here . . .

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s