OO issues in python

Ali El Dada eldada at mdstud.chalmers.se
Wed Dec 17 07:10:50 EST 2003


ok thanks, i understood my mistake, now to the solution:


Albert Hofkamp wrote:

> 
> If the parent and the child class need to share data, you either put the
> data in the sub-class (ie Child), or you create a new class that holds
> the data where both the parent and the child have access to.
> 

well the first solution is not feasible with me because i may have more 
classes and subclasses that may need this information (it is like a 
dictionary that has some global information, e.g. about the environment)

so do you advise me to take the second solution, creating a class called 
Global that any other class can access?? as in: (not tested)

class Global:
	user_home = os.environ['HOME']
	my_app_data = 'C:\\Program Files\\MyApp'

class AnyClass:
	self.user_home = Global.user_home





More information about the Python-list mailing list