Global Variables in OOP and Python

Steven D'Aprano steve at REMOVETHIScyber.com.au
Sat Dec 31 22:31:59 EST 2005


On Sat, 31 Dec 2005 21:21:29 +0000, Dennis Lee Bieber wrote:

> On Sat, 31 Dec 2005 11:37:38 +1100, Steven D'Aprano
> <steve at REMOVETHIScyber.com.au> declaimed the following in
> comp.lang.python:
> 
>> 
>> Do you mean something like this?
>> 
>> # Module care_and_feeding
>> 
>> import birds
>> import foods
>> 
>> def feed_my_pet():
>>     pet = birds.Parrot("Norwegian Blue")
>>     snack = foods.Spam("A tasty meat-like treat")
>>     pet.eats(snack)
>>     return "Yummy!"
>> 
>> 
>> That is a good way of handling the problem.
>>
> 	Except for the minor facet that you are buying a new parrot each
> time, and the bird dies after going "Yummy!" <G>

It's a Norwegian Blue with beautiful plumage. It's not dead, it's just
pining for the fjords.



-- 
Steven.




More information about the Python-list mailing list