Changing the private variables content

R

Ryniek90

Hi.
I'm writing some class, and decided to use inside private method and
some private variables. While with method i haven't got any problem's
with variables i have.
Maybe some example.
A class with private method and private variable:

" #
def __init__(self):
self._number = 1
#
def _secret(self):
print self._number
def showit(self):
print "Secret number is:\n"
self._secret()
Secret number is:

1"

As You can see, i made class with private method and private variable
inside __init__ constructor. I've changed also the variable value, but
outside class.
I've got problem with changing some variable value _inside__my_ class,
which i'm writing.
I've searched over google, some tuts with topics about operations on
private variables, but didn't found anything - only how to make them,
but no how to assign new objects/override them with new content (and
other advanced and helpful options).

If someone could help me, it would be great.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top