mbikinyi brat wrote:
Dear all,
Here are two functions printme and change quite spaced apart. When executed the output in bold are joined. What can I do so that the results are separate in two blocks?
?
#Function definition is here
def printme(str):
??? "This prints a passed string into this function"
??? print str
??? return
#Now you can call printme function
printme("I'm first call to user defined function!")
printme("Again second call to the same function")
?
?
#Function definition is here
def changeme(mylist):
??? "THIS CHANGES A PASSED LIST INTO THIS FUNCTION"
??? mylist.append([1, 2,3,4])
???
??? return
" now you can call the changme function"
mylist=[10, 20, 30]
print "valuse outside the function:", mylist
print "values inside this function:", mylist
?
?
?
I'm first call to user defined function!
Again second call to the same function
valuse outside the function: [10, 20, 30]
values inside this function: [10, 20, 30]
Regards,
Henry
I can't see "bold," in a text email. But presuming you're wondering why
the two output lines are deferred: starting "I'm first..." and "Again
second..." I wonder as well.
When I try to replicate your situation, I'm starting python.exe at the
XP Windows command prompt. It starts like this:
M:\>c:\ProgFiles\Python26\python.exe
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit
(Intel)] on win32
What does yours say?
Anyway when I type exactly what you did, I get several errors. So I
suspect your transcript isn't faithful. You really should copy&paste
from the console to the message.
So I add indentation, and blank lines as appropriate, and as expected, I
see each of those two lines echoes immediately after the corresponding
call to printme().
I suspect you're doing this inside some shell tool, perhaps in some IDE,
not at the command prompt.
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor