On Sat, Feb 04 2012,bob gailer wrote: > On 2/4/2012 9:38 AM, Sivaram Neelakantan wrote: >> While trying out code, I have trouble following the difference between >> >> return True vs print True and the same with False. If I use return >> for the True/False statements, nothing gets printed. Why? > > Why did you expect something to be printed?
err...return sends something back as in True or False? > > Perhaps you are confused between what happens in the interactive > window vs running a program? Possibly. But I was coding in an Emacs buffer and sending it to the python subprocess from within Emacs. Does that have anything to do with it? > > Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit > (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. >>>> def f(): > ... return True > ... >>>> f() > True >>>> def g(): > ... print True > ... >>>> g() > True >>>> print f() > True >>>> print g() > True > None > > In the interactive window, when you call a function, Python displays > the returned value. When you run a program with a call to a > function, Python does NOT display the returned value. > > A function that does not execute a return will return None; in the > interactive window nothing is displayed. > > Is that sufficient? Right, thanks for this, will check this thing out again. sivaram -- _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor