Some Minor questions on Class and Functions
joy99
subhakolkata1234 at gmail.com
Sat Mar 19 19:57:58 EDT 2011
Dear Group,
I am trying to pose two small questions.
1) I am using Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.
1500 32 bit (Intel)] on win32 Type "copyright", "credits" or
"license()" for more information, on WINXP SP2.
As I am writing a code for class like the following:
IDLE 2.6.5
>>> class Message:
def __init__(self,str1):
self.text="MY NAME"
def printmessage(self):
print self.text
It works fine as can be seen in the result:
>>> x1=Message(1)
>>> x1.printmessage()
MY NAME
Now if I open a new window and write the same code value in
printmessage is giving arbitrary or no values.
Am I doing any problem in writing the code?
2) Suppose I have a code:
>>> def hello():
print "HELLO SIR"
Can I write another function where I can call the value of this
function or manipulate it?
If any learned member can slightly help me out.
Thanks in advance,
Best Regards,
Subhabrata.
More information about the Python-list
mailing list