[Tutor] <function animals at 0x662f0> what does it mean?

Mehta, Amar amar.mehta at lehman.com
Mon Nov 13 18:07:27 CET 2006


the function animals returns a reference to itself.  the reference is
printed in oldMac

oldMac can be changed to remove the print statements

def oldMac():
	animals("cow", "moo")
	animals("pig", "oink")
	animals("horse", "neigh")
	animals("dog", "woof")
	animals("cat", "meow")

you also don't need to return anything from the animals function as it
stands. the function as it stands is merely for side effects (ie
printing various strings).

<function animals at 0x66030> is the location of the code for the
function in the computers RAM.


-----Original Message-----
From: tutor-bounces at python.org [mailto:tutor-bounces at python.org] On
Behalf Of Kristinn Didriksson
Sent: Monday, November 13, 2006 11:51 AM
To: tutor at python.org
Subject: [Tutor] <function animals at 0x662f0> what does it mean?

Hello,
This is my first program calling functions :) It worked nicely except
for the message above. Can anyone explain what the message means.
Thanks,
Kristinn

Program
-----------------------------
# a program that prints the lyrics for Old Mcdonal had a farm for 5
different animals.
# this will have two functions: oldMac and animals # two functions will
be passed: animal and sound

def animals(animal, sound):
	# print out the lyrics calling the subroutine for aminals
	print "Old MacDonald had a farm, Ee-igh, Ee-igh, Oh!"
	print "And on the farm he had a ", animal + ", Ee-igh, Ee-igh,
Oh!"
	print "With a", sound + ",", sound, "here and a" , sound + ",",
sound + " there."
	print "Here a", sound + ", there a", sound + ", everyehere a",
sound  
+ ",", sound + "."
	print "Old MacDonald had a farm, Ee-igh, Ee-igh, Oh!"
	print
	return animals



def oldMac():
	print animals("cow", "moo")
	print animals("pig", "oink")
	print animals("horse", "neigh")
	print animals("dog", "woof")
	print animals("cat", "meow")
	
oldMac()


------------------------------
Output
-----------------------------
Old MacDonald had a farm, Ee-igh, Ee-igh, Oh!
And on the farm he had a  cow, Ee-igh, Ee-igh, Oh!
With a moo, moo here and a moo, moo there.
Here a moo, there a moo, everyehere a moo, moo.
Old MacDonald had a farm, Ee-igh, Ee-igh, Oh!

<function animals at 0x66030>
Old MacDonald had a farm, Ee-igh, Ee-igh, Oh!
And on the farm he had a  pig, Ee-igh, Ee-igh, Oh!
With a oink, oink here and a oink, oink there.
Here a oink, there a oink, everyehere a oink, oink.
Old MacDonald had a farm, Ee-igh, Ee-igh, Oh!

<function animals at 0x66030>
Old MacDonald had a farm, Ee-igh, Ee-igh, Oh!
And on the farm he had a  horse, Ee-igh, Ee-igh, Oh!
With a neigh, neigh here and a neigh, neigh there.
Here a neigh, there a neigh, everyehere a neigh, neigh.
Old MacDonald had a farm, Ee-igh, Ee-igh, Oh!

<function animals at 0x66030>
Old MacDonald had a farm, Ee-igh, Ee-igh, Oh!
And on the farm he had a  dog, Ee-igh, Ee-igh, Oh!
With a woof, woof here and a woof, woof there.
Here a woof, there a woof, everyehere a woof, woof.
Old MacDonald had a farm, Ee-igh, Ee-igh, Oh!

<function animals at 0x66030>
Old MacDonald had a farm, Ee-igh, Ee-igh, Oh!
And on the farm he had a  cat, Ee-igh, Ee-igh, Oh!
With a meow, meow here and a meow, meow there.
Here a meow, there a meow, everyehere a meow, meow.
Old MacDonald had a farm, Ee-igh, Ee-igh, Oh!

<function animals at 0x66030>

-------------------------------


_______________________________________________
Tutor maillist  -  Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

This message is intended only for the personal and confidential use of the designated recipient(s) named above.  If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited.  This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers.  Email transmission cannot be guaranteed to be secure or error-free.  Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such.  All information is subject to change without notice.

--------
IRS Circular 230 Disclosure:
Please be advised that any discussion of U.S. tax matters contained within this communication (including any attachments) is not intended or written to be used and cannot be used for the purpose of (i) avoiding U.S. tax related penalties or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein.





More information about the Tutor mailing list