[Tutor] Defining a function (Joseph Q.)

Joseph Quigley cpu.crazy at gmail.com
Wed Apr 13 19:05:29 CEST 2005


Oh, now I understand....

def silly(a_name_I_picked_at_random):   # well, not quite

...     print a_name_I_picked_at_random     # at random ;-)
...


>>>silly(42)

42

The name a_name_I_picked_at_random is like a "placeholder" inside the
function for whatever input we gave to the function. And *that* can be
any object

So you can have silly say something serious like:

def silly(a_name_I_picked_at_random):   # well, not quite

         print a_name_I_picked_at_random     # at random ;-)

def silly(this_is_serious):
         print 'this is serious"

But I get an error!
Traceback (most recent call last):
   File "C:\Python24\saved\tmp1.py", line 7, in -toplevel-
     silly(this_is_serious)
NameError: name 'this_is_serious' is not defined

But you can have silly say something silly and also say something serious 
right? If so.... how?

args has confused me, but I'm slowly picking it up.

Thanks Brian, Jeff, Liam for your help.
         Joseph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20050413/f36c07e0/attachment.html


More information about the Tutor mailing list