[Python-Dev] Dynamic class inheritance something else

2005-06-14 Thread Vero
Hi. My name is Veronica, I am a master student at UNAM. I am working on something related to Artificial Inteligence and I have been looking for the most appropriated programming language to implement my algorithms. I found python to be very close to what I need, but there are still a couple of details that I haven't been able to solve.

First, (and most important) I would like to be able to dynamically modify the classes from which a class inherits.I haven't found any way to do it with the language as it is. If thereis a way, any suggestion will be truly appreciated. If I had to modify the source code to achieve this, I hope that you could give me some hints;I have an idea of how something like this could be achieved but since I don't know deeply the python sourcodeI could get lost.

Second, since my program will be modifying classes during run time, I would like to have a way to write on a file the python code that would have defined the class with the functions and attributes as they were left, just as if it had been writen like that at the very begining. I need it to be python code because I will be using that latter. Maybe I will have to solve this second problem by myself but I just wrote in case anybody had a good idea.

Thank you very much for your help.


Vero
 
  La sociedad es inherentemente democrática: la mayoría decide si pensar por si misma o si dejar que alguien más les diga qué pensar. http://mx.geocities.com/aqua_azul_2000/ 

		  
Do You Yahoo!? 
La mejor conexión a Internet y 2GB extra a tu correo por $100 al mes. http://net.yahoo.com.mx 
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Dynamic class inheritance something else

2005-06-14 Thread Aahz
On Tue, Jun 14, 2005, Vero wrote:

 Hi.  My name is Veronica, I am a master student at UNAM.  I am working
 on something related to Artificial Inteligence and I have been looking
 for the most appropriated programming language to implement my
 algorithms.  I found python to be very close to what I need, but there
 are still a couple of details that I haven't been able to solve.

Hi Veronica,

python-dev is for future development of Python; for questions about
using Python, please go to comp.lang.python.  Thanks.
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

f u cn rd ths, u cn gt a gd jb n nx prgrmmng.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Dynamic class inheritance something else

2005-06-14 Thread Guido van Rossum
On 6/14/05, Vero [EMAIL PROTECTED] wrote:
 Hi.  My name is Veronica, I am a master student at UNAM.  I am working on
 something related to Artificial Inteligence and I have been looking for the
 most appropriated programming language to implement my algorithms.  I found
 python to be very close to what I need, but there are still a couple of
 details that I haven't been able to solve. 
   
 First, (and most important) I would like to be able to dynamically modify
 the classes from which a class inherits.  I haven't found any way to do it
 with the language as it is.  If there is a way, any suggestion will be truly
 appreciated.  If I had to modify the source code to achieve this, I hope
 that you could give me some hints; I have an idea of how something like this
 could be achieved but since I don't know deeply the python sourcode I could
 get lost. 

I wonder if assignment to __class__ (for instances) or to __bases__
(for classes) is what you are looking for?

 class C: 
 def foo(self): print foo

 class D:
 def foo(self): print D.foo

 x = C()
 x.__class__ = D
 x.foo()
D.foo
 x.__class__ = C
 x.foo()
foo
 

 Second, since my program will be modifying classes during run time, I would
 like to have a way to write on a file the python code that would have
 defined the class with the functions and attributes as they were left, just
 as if it had been writen like that at the very begining.  I need it to be
 python code because I will be using that latter.  Maybe I will have to solve
 this second problem by myself but I just wrote in case anybody had a good
 idea. 

That one's not so easy; there's no standard solution for this problem.
I recommend that you follow Aahz' suggestion of asking on c.l.py
instead.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com