OO issues in python

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


ok that settles everything.. thanks a million!!!


Regards,
Ali Dada


Lutz Horn wrote:
> Hi,
> 
> * Ali El Dada <eldada at mdstud.chalmers.se> [17 Dez 2003]:
> 
>>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) 
> 
> 
> What's the problem with passing the context to every instance of a 
> subclass? It's only a parameter in a constructor or the call of a 
> method like setContext().
> 
> 
>>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
> 
> 
> No, don't use global data.
> 
> Lutz





More information about the Python-list mailing list