Re: Global Variables in OOP and Python

2006-01-01 Thread Steven D'Aprano
On Sun, 01 Jan 2006 06:48:48 -0800, Kay Schluehr wrote: >> Agree about from module import * being bad, but it is still generally poor >> practice for the same reason using global variables is generally poor >> practice. > > No, I don't think so. The general wisdom is that global variables are > b

Re: Global Variables in OOP and Python

2006-01-01 Thread Kay Schluehr
Steven D'Aprano wrote: > On Fri, 30 Dec 2005 20:00:51 -0500, Mike Meyer wrote: > > > >> The other way I thought of is to create a separate class that consists > >> of the variables and to use the > >> > >> from import * > >> > >> in all of the files (namespaces) where it is needed. > > > > Except

Re: Global Variables in OOP and Python

2005-12-31 Thread Steven D'Aprano
On Sat, 31 Dec 2005 21:21:29 +, Dennis Lee Bieber wrote: > On Sat, 31 Dec 2005 11:37:38 +1100, Steven D'Aprano > <[EMAIL PROTECTED]> declaimed the following in > comp.lang.python: > >> >> Do you mean something like this? >> >> # Module care_and_feeding >> >> import birds >> import foods >>

Re: Global Variables in OOP and Python

2005-12-30 Thread Steven D'Aprano
On Fri, 30 Dec 2005 20:00:51 -0500, Mike Meyer wrote: >> The other way I thought of is to create a separate class that consists >> of the variables and to use the >> >> from import * >> >> in all of the files (namespaces) where it is needed. > > Except for one detail, this is a Pythonesque meth

Re: Global Variables in OOP and Python

2005-12-30 Thread Brian van den Broek
Gary Herron said unto the world upon 30/12/05 08:03 PM: > newbie wrote: > > >>Hello, >> >>I have questions about global variables in OOP (in general) and Python >>(in specific). I understand (I think) that global variables are >>generally not a good idea. However, if there are variables that nee

Re: Global Variables in OOP and Python

2005-12-30 Thread Gary Herron
newbie wrote: >Hello, > >I have questions about global variables in OOP (in general) and Python >(in specific). I understand (I think) that global variables are >generally not a good idea. However, if there are variables that need to >be accessed by a number of classes that exists in separate nam

Re: Global Variables in OOP and Python

2005-12-30 Thread Mike Meyer
"newbie" <[EMAIL PROTECTED]> writes: > So far, I have approached the problem by making the variables > attributes of one class and passing instances of the class as variables > to the other class' methods. That's the standard way to do it in OO languages. > The other way I thought of is to create

Re: Global Variables in OOP and Python

2005-12-30 Thread Steven D'Aprano
On Fri, 30 Dec 2005 15:03:54 -0800, newbie wrote: > Hello, > > I have questions about global variables in OOP (in general) and Python > (in specific). I understand (I think) that global variables are > generally not a good idea. However, if there are variables that need to > be accessed by a num

Global Variables in OOP and Python

2005-12-30 Thread newbie
Hello, I have questions about global variables in OOP (in general) and Python (in specific). I understand (I think) that global variables are generally not a good idea. However, if there are variables that need to be accessed by a number of classes that exists in separate namespaces (files), what