Let's say I have a class called Chicken in a file called Chicken.py Now let's say I want to add a method called getSize() to the Chicken class. It's a piece of cake to add the method in the Chicken.py file. But, is it possible to add the method to the Chicken class, but have that method in a different file, i.e. some file other than Chicken.py? Thanks, Dan
On Thu, 9 Mar 2000, Daniel G. Rusch wrote:
Let's say I have a class called Chicken in a file called Chicken.py
Now let's say I want to add a method called getSize() to the Chicken class. It's a piece of cake to add the method in the Chicken.py file.
But, is it possible to add the method to the Chicken class, but have that method in a different file, i.e. some file other than Chicken.py?
It really depends on how bad your intentions are. Could you use subclassing? Or do you want to add methods dynamically after instance creation? P
In this case subclassing won't work and I'm not needing to do this dynamically. DR Pavlos Christoforou wrote:
On Thu, 9 Mar 2000, Daniel G. Rusch wrote:
Let's say I have a class called Chicken in a file called Chicken.py
Now let's say I want to add a method called getSize() to the Chicken class. It's a piece of cake to add the method in the Chicken.py file.
But, is it possible to add the method to the Chicken class, but have that method in a different file, i.e. some file other than Chicken.py?
It really depends on how bad your intentions are. Could you use subclassing? Or do you want to add methods dynamically after instance creation?
P
From: "Daniel G. Rusch" <drusch@globalcrossing.com>
In this case subclassing won't work and I'm not needing to do this dynamically.
DR
You may want to have alook at the Zope Product code for Zope Studio. I added methods to the Application class, exactly what you want (watch it, long URL, you may have to reconstruct): http://cvs.zope.org/cgi-bin/cvsweb.cgi/ZopeMozilla/ZopeStudio/ZopeProduct/Zo peStudio/ZopeStudioRDF.py?rev=1.2&content-type=text/x-cvsweb-markup The important bits are 'import OFS.Application', and to assignments to class members in OFS.Application.Application: OFS.Application.Application.zsTreeRoot = zsTreeRoot OFS.Application.Application.zsContainerRDF = zsContainerRDF Martijn Pieters | Software Engineer mailto:mj@digicool.com | Digital Creations http://www.digicool.com/ | Creators of Zope http://www.zope.org/ | The Open Source Web Application Server ---------------------------------------------
participants (3)
-
Daniel G. Rusch -
Martijn Pieters -
Pavlos Christoforou