Re: CONSTRUCT - Python's way of Ruby's alias_method

2006-06-10 Thread Maric Michaud
Le Vendredi 09 Juin 2006 20:06, Ilias Lazaridis a écrit : the code below works, but has the limitation that I cannot import the syncdb_hook within django.core.management. In [4]: from b import CONS In [5]: import b In [6]: b.CONS = 3 In [7]: CONS Out[7]: 5 In [8]: from b import CONS In

Re: CONSTRUCT - Python's way of Ruby's alias_method

2006-06-10 Thread Ilias Lazaridis
Maric Michaud wrote: Le Vendredi 09 Juin 2006 20:06, Ilias Lazaridis a écrit : the code below works, but has the limitation that I cannot import the syncdb_hook within django.core.management. In [4]: from b import CONS In [5]: import b In [6]: b.CONS = 3 In [7]: CONS Out[7]: 5

Re: CONSTRUCT - Python's way of Ruby's alias_method

2006-06-09 Thread Ilias Lazaridis
Maric Michaud wrote: Le Jeudi 08 Juin 2006 14:28, Ilias Lazaridis a écrit : Another possibility is to enlink (hook?) the functionality into an existent function Is there any way (beside a patch) to alter the behaviour to an existing function. Is ther a python construct similar to the

Re: CONSTRUCT - Python's way of Ruby's alias_method

2006-06-09 Thread Duncan Booth
Ilias Lazaridis wrote: #patch_service.py from toto import service def my_impl(self, *args) : old_result = self._old_method(*args) # ... return new_result if not hasattr(service, '_old_method') : service._old_method = service.method service.method = my_impl

Re: CONSTRUCT - Python's way of Ruby's alias_method

2006-06-09 Thread Ilias Lazaridis
Duncan Booth wrote: Ilias Lazaridis wrote: #patch_service.py from toto import service def my_impl(self, *args) : old_result = self._old_method(*args) # ... return new_result if not hasattr(service, '_old_method') : service._old_method = service.method

Re: CONSTRUCT - Python's way of Ruby's alias_method

2006-06-09 Thread Ilias Lazaridis
Slawomir Nowaczyk wrote: On Thu, 08 Jun 2006 15:28:39 +0300 Ilias Lazaridis [EMAIL PROTECTED] wrote: # *IMPORT* # # I would like to know, if this construct is valid, or if it can # result in problems (that I do not see as a newcomer): The intricacies of import are far beyond me, but

CONSTRUCT - Python's way of Ruby's alias_method

2006-06-08 Thread Ilias Lazaridis
I have a few small questions subjecting python functionality, most importantly the alias_method. - *IMPORT* I would like to know, if this construct is valid, or if it can result in problems (that I do not see as a newcomer): 1082try: 1083from django.rework.evolve

Re: CONSTRUCT - Python's way of Ruby's alias_method

2006-06-08 Thread Duncan Booth
Ilias Lazaridis wrote: I would like to know, if this construct is valid, or if it can result in problems (that I do not see as a newcomer): 1082try: 1083from django.rework.evolve import evolvedb 1084except ImportError: 1085def evolvedb():

Re: CONSTRUCT - Python's way of Ruby's alias_method

2006-06-08 Thread Duncan Booth
Ilias Lazaridis wrote: Is there any way (beside a patch) to alter the behaviour to an existing function. Is ther a python construct similar to the alias_method of Ruby: This is a Python list. Would you care to explain what alias_method does? (example from an simple evolution support for

Re: CONSTRUCT - Python's way of Ruby's alias_method

2006-06-08 Thread Maric Michaud
Le Jeudi 08 Juin 2006 14:28, Ilias Lazaridis a écrit : Another possibility is to enlink (hook?) the functionality into an existent function Is there any way (beside a patch) to alter the behaviour to an existing function. Is ther a python construct similar to the alias_method of Ruby: No,

Re: CONSTRUCT - Python's way of Ruby's alias_method

2006-06-08 Thread Tim N. van der Leeuw
Since your question is so much about Django, you might want to ask on Django groups. Oops, you're not welcome there anymore, almost forgot. But if merely reading the subject of a posting I already know who's the poster, it's perhaps a bad sign. Further readers of this thread might be interested

Re: CONSTRUCT - Python's way of Ruby's alias_method

2006-06-08 Thread Maric Michaud
Le Jeudi 08 Juin 2006 15:15, Duncan Booth a écrit : but the more usual way is just to call the original method directly in the base class. class SqliteAdapter(BaseClass): def create_table(self, *args) self.table_evolve(*args) result = BaseClass.create_table(self, *args)

Re: CONSTRUCT - Python's way of Ruby's alias_method

2006-06-08 Thread Ilias Lazaridis
Tim N. van der Leeuw wrote: [...] http://case.lazaridis.com/wiki/Please . -- http://lazaridis.com -- http://mail.python.org/mailman/listinfo/python-list

Re: CONSTRUCT - Python's way of Ruby's alias_method

2006-06-08 Thread Ilias Lazaridis
Maric Michaud wrote: Le Jeudi 08 Juin 2006 15:15, Duncan Booth a écrit : but the more usual way is just to call the original method directly in the base class. class SqliteAdapter(BaseClass): def create_table(self, *args) self.table_evolve(*args) result =

Re: CONSTRUCT - Python's way of Ruby's alias_method

2006-06-08 Thread Ilias Lazaridis
Duncan Booth wrote: Ilias Lazaridis wrote: I would like to know, if this construct is valid, or if it can result in problems (that I do not see as a newcomer): 1082try: 1083from django.rework.evolve import evolvedb 1084except ImportError: 1085

Re: CONSTRUCT - Python's way of Ruby's alias_method

2006-06-08 Thread Slawomir Nowaczyk
On Thu, 08 Jun 2006 06:05:35 -0700 Tim N. van der Leeuw [EMAIL PROTECTED] wrote: # Since your question is so much about Django, you might want to ask # on Django groups. Now *that*, and the rest of your post, was uncalled for. This thread is perfectly on topic for this list and the question

Re: CONSTRUCT - Python's way of Ruby's alias_method

2006-06-08 Thread Slawomir Nowaczyk
On Thu, 08 Jun 2006 15:28:39 +0300 Ilias Lazaridis [EMAIL PROTECTED] wrote: # *IMPORT* # # I would like to know, if this construct is valid, or if it can # result in problems (that I do not see as a newcomer): The intricacies of import are far beyond me, but FWIW I do not see anything wrong in