Re: CONSTRUCT - New/Old Style Classes, build-in/extension types

2006-09-25 Thread Aahz
In article <[EMAIL PROTECTED]>, Ilias Lazaridis <[EMAIL PROTECTED]> wrote: > >Have those old style classes any benefits? Yes, if you want your code to run on Python 2.1 and earlier. -- Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraft.com/ "LL YR VWL R BLNG T S" -- www.nanc

Re: CONSTRUCT - New/Old Style Classes, build-in/extension types

2006-09-23 Thread Ilias Lazaridis
Steve Holden wrote: > Ilias Lazaridis wrote: >> Steve Holden wrote: ... >>> Though of course the easiest way to enforce your classes to new style is >>> to begin each module with >>> >>> __metaclass__ = type >> >> I assume placing this in the central site import (e.g. >> sitecustomize.py) would col

Re: CONSTRUCT - New/Old Style Classes, build-in/extension types

2006-09-22 Thread Steve Holden
Ilias Lazaridis wrote: > Steve Holden wrote: > >>Paul Boddie wrote: >> >>>Ilias Lazaridis wrote: >> >>[...] >> Have those old style classes any benefits? >>> >>> >>>That you don't have to write the bizarre conceptual accident that is >>>"(object)" when declaring a "top-level" class? >>> >> >>T

Re: CONSTRUCT - New/Old Style Classes, build-in/extension types

2006-09-22 Thread Ilias Lazaridis
Paul Boddie wrote: > Ilias Lazaridis wrote: ... (helpful comments) > > Have those old style classes any benefits? > > That you don't have to write the bizarre conceptual accident that is > "(object)" when declaring a "top-level" class? This was most possibly done for back-compatibility reasons.

Re: CONSTRUCT - New/Old Style Classes, build-in/extension types

2006-09-22 Thread Ilias Lazaridis
Steve Holden wrote: > Paul Boddie wrote: > > Ilias Lazaridis wrote: > [...] > >>Have those old style classes any benefits? > > > > > > That you don't have to write the bizarre conceptual accident that is > > "(object)" when declaring a "top-level" class? > > > Though of course the easiest way to en

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-22 Thread Ilias Lazaridis
Steve Holden wrote: > Michele Simionato wrote: > > (I don't believe I am responding to a notorious troll ...) > > > Believe it. You are. Ain't life a bitch? :-) > > > One (bad) solution is to write in your sitecustomize.py the following: > > > > $ echo /usr/lib/python/sitecustomize.py > > import __

Re: CONSTRUCT - New/Old Style Classes, build-in/extension types

2006-09-22 Thread Steve Holden
Paul Boddie wrote: > Ilias Lazaridis wrote: [...] >>Have those old style classes any benefits? > > > That you don't have to write the bizarre conceptual accident that is > "(object)" when declaring a "top-level" class? > Though of course the easiest way to enforce your classes to new style is t

Re: CONSTRUCT - New/Old Style Classes, build-in/extension types

2006-09-22 Thread Paul Boddie
Ilias Lazaridis wrote: > Fredrik Lundh wrote: > > Ilias Lazaridis wrote: > > > >> note: I am aware about search engines. > > > > but you're incapable of using them, or ? Well, "Python new-style old-style classes" in Google gives a range of discussions, but an old version of the definitive guide [1

Re: CONSTRUCT - New/Old Style Classes, build-in/extension types

2006-09-22 Thread Steve Holden
Ilias Lazaridis wrote: > Fredrik Lundh wrote: > >>Ilias Lazaridis wrote: >> >> >>>note: I am aware about search engines. >> >>but you're incapable of using them, or ? > > > - > > >>>I ask for documentation which other developers have found useful >> >>most recent Python books contains good dis

Re: CONSTRUCT - New/Old Style Classes, build-in/extension types

2006-09-22 Thread Ilias Lazaridis
Fredrik Lundh wrote: > Ilias Lazaridis wrote: > >> note: I am aware about search engines. > > but you're incapable of using them, or ? - >> I ask for documentation which other developers have found useful > > most recent Python books contains good discussions of the things you're > asking for.

Re: CONSTRUCT - New/Old Style Classes, build-in/extension types

2006-09-22 Thread Ilias Lazaridis
Ben Finney wrote: > "Ilias Lazaridis" <[EMAIL PROTECTED]> writes: > >> Where can I find _compact_ documentation about > > Can you tell us what is lacking about the documentation at > http://www.python.org/doc/> ? Specifically, what problems have > you found in understanding these topics from the

Re: CONSTRUCT - New/Old Style Classes, build-in/extension types

2006-09-22 Thread Ben Finney
"Ilias Lazaridis" <[EMAIL PROTECTED]> writes: > Where can I find _compact_ documentation about Can you tell us what is lacking about the documentation at http://www.python.org/doc/> ? Specifically, what problems have you found in understanding these topics from the documentation available at that

Re: CONSTRUCT - New/Old Style Classes, build-in/extension types

2006-09-22 Thread Fredrik Lundh
Ilias Lazaridis wrote: > note: I am aware about search engines. but you're incapable of using them, or ? > I ask for documentation which other developers have found useful most recent Python books contains good discussions of the things you're asking for. maybe you should buy a book ? --

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-20 Thread Ilias Lazaridis
George Sakkis wrote: > Ilias Lazaridis wrote: > > > I like to add a method "writeDebug(self, msg)" to all (or the most > > possible) classes in the system. > > > > How do I do this? > > > > * with new style classes > > * with old style classes > > Short answer: you can't do it for builtin or extens

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-20 Thread Steve Holden
Michele Simionato wrote: > (I don't believe I am responding to a notorious troll ...) > Believe it. You are. Ain't life a bitch? :-) > One (bad) solution is to write in your sitecustomize.py the following: > > $ echo /usr/lib/python/sitecustomize.py > import __builtin__ > > class Object(object)

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-20 Thread Michele Simionato
(I don't believe I am responding to a notorious troll ...) One (bad) solution is to write in your sitecustomize.py the following: $ echo /usr/lib/python/sitecustomize.py import __builtin__ class Object(object): def debug(self): print 'some debug info' __builtin__.object = Object th

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-20 Thread Ilias Lazaridis
MonkeeSage wrote: > Ilias Lazaridis wrote: >> no, I don't know it. > > OK...so how do you evaluate a language when you don't know its basic > operations? Hmmm, sounds fishy. The learning-process is an important part of the evaluation. >> how do I define something into the top-level namespace? I

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-20 Thread MonkeeSage
Ilias Lazaridis wrote: > no, I don't know it. OK...so how do you evaluate a language when you don't know its basic operations? Hmmm, sounds fishy. > how do I define something into the top-level namespace? I assume I > could place it into the root-package of my project, into the __init__ > functio

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-20 Thread Ilias Lazaridis
MonkeeSage wrote: > Ilias Lazaridis wrote: > > where do I place this function... > > The place where you want it to be. > > > ...thus it becomes available within class "Foo" and all other Classes? > > Anything defined in the top-level (i.e., the sys.modules['__main__'] > namespace) is accessible in

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-19 Thread George Sakkis
Ilias Lazaridis wrote: > I like to add a method "writeDebug(self, msg)" to all (or the most > possible) classes in the system. > > How do I do this? > > * with new style classes > * with old style classes Short answer: you can't do it for builtin or extension types: >>> list.writeDebug = lambda m

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-19 Thread Steve Holden
Ilias Lazaridis wrote: > MonkeeSage wrote: > >>Ilias Lazaridis wrote: >> >>>How do I do this? >> >>It's easy: >> >>def writeDebug(msg): >> print "I do not debug things, I _evaluate_ with professionals on the >>industries! See ticket 547!\n" \ >>"Oh yeah, and %s" % msg > > > where do I p

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-19 Thread MonkeeSage
Ilias Lazaridis wrote: > where do I place this function... The place where you want it to be. > ...thus it becomes available within class "Foo" and all other Classes? Anything defined in the top-level (i.e., the sys.modules['__main__'] namespace) is accessible in every scope...but I assume you a

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-19 Thread Ilias Lazaridis
MonkeeSage wrote: > Ilias Lazaridis wrote: > > How do I do this? > > It's easy: > > def writeDebug(msg): > print "I do not debug things, I _evaluate_ with professionals on the > industries! See ticket 547!\n" \ > "Oh yeah, and %s" % msg where do I place this function... > ... > class F

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-19 Thread Ilias Lazaridis
Diez B. Roggisch wrote: > Ilias Lazaridis wrote: > > Ilias Lazaridis wrote: > >> I understand that I can use __metaclass__ to create a class which > >> modifies the behaviour of another class. > >> > >> How can I add this metaclass to *all* classes in the system? > >> > >> (In ruby I would alter th

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-19 Thread MonkeeSage
Ilias Lazaridis wrote: > How do I do this? It's easy: def writeDebug(msg): print "I do not debug things, I _evaluate_ with professionals on the industries! See ticket 547!\n" \ "Oh yeah, and %s" % msg ... class Foo: writeDebug("how can I configure the interpreter for understand Klingo

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-19 Thread Diez B. Roggisch
Ilias Lazaridis wrote: > Ilias Lazaridis wrote: >> I understand that I can use __metaclass__ to create a class which >> modifies the behaviour of another class. >> >> How can I add this metaclass to *all* classes in the system? >> >> (In ruby I would alter the "Class" class) > > I got confused fr

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-19 Thread Ilias Lazaridis
Ilias Lazaridis wrote: > I understand that I can use __metaclass__ to create a class which > modifies the behaviour of another class. > > How can I add this metaclass to *all* classes in the system? > > (In ruby I would alter the "Class" class) I got confused from the discussion about __metaclass_

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-19 Thread Georg Brandl
Diez B. Roggisch wrote: >>> >>> I think '__metaclass__ = whatever' affects only the creation of >>> classes that >>> would otherwise be old-style classes? >> >> Wrong. >> >> If you set __metaclass__ = type, every class in that module will be >> new-style. >> >> If you set __metaclass__ = MyCla

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-19 Thread Damjan
>>> __metaclass__ = whatever >>> >>> at the top of each module whose classes are to get the new behavior. >> >> I think '__metaclass__ = whatever' affects only the creation of classes >> that would otherwise be old-style classes? > > Wrong. > > If you set __metaclass__ = type, every class in th

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-19 Thread Diez B. Roggisch
>> >> I think '__metaclass__ = whatever' affects only the creation of >> classes that >> would otherwise be old-style classes? > > Wrong. > > If you set __metaclass__ = type, every class in that module will be > new-style. > > If you set __metaclass__ = MyClass, and MyClass inherits from , eve

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-18 Thread Georg Brandl
Damjan wrote: >>> I understand that I can use __metaclass__ to create a class which >>> modifies the behaviour of another class. >>> >>> How can I add this metaclass to *all* classes in the system? >>> >>> (In ruby I would alter the "Class" class) >> >> You'd have to set >> >> __metaclass__ = w

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-18 Thread Ilias Lazaridis
Calvin Spealman wrote: > On 18 Sep 2006 20:23:03 -0700, Ilias Lazaridis <[EMAIL PROTECTED]> wrote: > > Steve Holden wrote: > > > Ilias Lazaridis wrote: > > ... > > > > http://www-128.ibm.com/developerworks/linux/library/l-pymeta.html > > > > > > > > I am not so much interested in old-style, as is s

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-18 Thread Calvin Spealman
On 18 Sep 2006 20:23:03 -0700, Ilias Lazaridis <[EMAIL PROTECTED]> wrote: > Steve Holden wrote: > > Ilias Lazaridis wrote: > ... > > > http://www-128.ibm.com/developerworks/linux/library/l-pymeta.html > > > > > > I am not so much interested in old-style, as is start production with > > > python 2.4

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-18 Thread Ilias Lazaridis
Steve Holden wrote: > Ilias Lazaridis wrote: ... > > http://www-128.ibm.com/developerworks/linux/library/l-pymeta.html > > > > I am not so much interested in old-style, as is start production with > > python 2.4 (possibly even with python 2.5). > > > > The fact remains that you won't be able to aff

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-18 Thread Paul McGuire
"Calvin Spealman" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On 17 Sep 2006 09:22:16 -0700, Ilias Lazaridis <[EMAIL PROTECTED]> > wrote: >> I understand that I can use __metaclass__ to create a class which >> modifies the behaviour of another class. >> >> How can I add this met

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-18 Thread Steve Holden
Ilias Lazaridis wrote: > Damjan wrote: > I understand that I can use __metaclass__ to create a class which modifies the behaviour of another class. How can I add this metaclass to *all* classes in the system? (In ruby I would alter the "Class" class) >>> >>>You'd have to

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-17 Thread Ilias Lazaridis
Damjan wrote: > >> I understand that I can use __metaclass__ to create a class which > >> modifies the behaviour of another class. > >> > >> How can I add this metaclass to *all* classes in the system? > >> > >> (In ruby I would alter the "Class" class) > > > > You'd have to set > > > > __metaclass

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-17 Thread Damjan
>> I understand that I can use __metaclass__ to create a class which >> modifies the behaviour of another class. >> >> How can I add this metaclass to *all* classes in the system? >> >> (In ruby I would alter the "Class" class) > > You'd have to set > > __metaclass__ = whatever > > at the top

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-17 Thread Georg Brandl
Ilias Lazaridis wrote: > I understand that I can use __metaclass__ to create a class which > modifies the behaviour of another class. > > How can I add this metaclass to *all* classes in the system? > > (In ruby I would alter the "Class" class) You'd have to set __metaclass__ = whatever at the

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-17 Thread Calvin Spealman
On 17 Sep 2006 09:22:16 -0700, Ilias Lazaridis <[EMAIL PROTECTED]> wrote: > I understand that I can use __metaclass__ to create a class which > modifies the behaviour of another class. > > How can I add this metaclass to *all* classes in the system? > > (In ruby I would alter the "Class" class) Th

Re: CONSTRUCT -

2006-09-12 Thread Ilias Lazaridis
Steve Holden wrote: > Simon Forman wrote: > > Fredrik Lundh wrote: > >>Simon Forman wrote: > >> > >>>I'm sorry, your post makes very little sense. > >> > >>you're somewhat new here, right ? ;-) > >> > > > > Yah, I've been posting here about three months now. Why, did I miss > > something? :-) >

Re: CONSTRUCT -

2006-09-07 Thread Georg Brandl
Steve Holden wrote: >> I am not a (python) domain expert. >> >> Thus I am asking here for available standard-solutions, before I >> implement an own solution. >> > There is no standard solution for the problem you mention. Because it's not a problem for most people ;) Georg -- http://mail.pyt

Re: CONSTRUCT -

2006-09-06 Thread lazaridis_com
Steve Holden wrote: > lazaridis_com wrote: > > Georg Brandl wrote: > >>lazaridis_com wrote: > >>>Georg Brandl wrote: > lazaridis_com wrote: > > >I would like to fulfill the following task: > > > >The construct: > > > >if __name__ == '__main__': > > > >should be

Re: CONSTRUCT -

2006-09-06 Thread Steve Holden
Simon Forman wrote: > Fredrik Lundh wrote: > >>Simon Forman wrote: >> >> >>>I'm sorry, your post makes very little sense. >> >>you're somewhat new here, right ? ;-) >> >> > > > > Yah, I've been posting here about three months now. Why, did I miss > something? :-) > Yes: the previous posts f

Re: CONSTRUCT -

2006-09-05 Thread Simon Forman
Fredrik Lundh wrote: > Simon Forman wrote: > > > I'm sorry, your post makes very little sense. > > you're somewhat new here, right ? ;-) > > Yah, I've been posting here about three months now. Why, did I miss something? :-) Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-li

Re: CONSTRUCT -

2006-09-05 Thread Steve Holden
lazaridis_com wrote: > Georg Brandl wrote: > >>lazaridis_com wrote: >> >>>Georg Brandl wrote: >>> lazaridis_com wrote: >I would like to fulfill the following task: > >The construct: > >if __name__ == '__main__': > >should be changed to something like: > >>>

Re: CONSTRUCT -

2006-09-05 Thread lazaridis_com
Georg Brandl wrote: > lazaridis_com wrote: > > Georg Brandl wrote: > >> lazaridis_com wrote: > >> > I would like to fulfill the following task: > >> > > >> > The construct: > >> > > >> > if __name__ == '__main__': > >> > > >> > should be changed to something like: > >> > > >> > if identifier.name =

Re: CONSTRUCT -

2006-09-04 Thread Georg Brandl
lazaridis_com wrote: > Georg Brandl wrote: >> lazaridis_com wrote: >> > I would like to fulfill the following task: >> > >> > The construct: >> > >> > if __name__ == '__main__': >> > >> > should be changed to something like: >> > >> > if identifier.name == '__main__': >> > >> > The term "identifier

Re: CONSTRUCT -

2006-09-03 Thread lazaridis_com
Simon Forman wrote: > lazaridis_com wrote: > > I would like to fulfill the following task: > > > > The construct: > > > > if __name__ == '__main__': > > > > should be changed to something like: > > > > if identifier.name == '__main__': ... > > Context: > > http://case.lazaridis.com/wiki/Lang > >

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-09-03 Thread lazaridis_com
lazaridis_com wrote: > lazaridis_com wrote: > > I would like to change the construct: > > > > if __name__ == '__main__': > ... > > Is there a standard way / naming to wrap "__name__" and other similar > attributes to an encapsulating class? ... see follow-up thread: http://groups.google.com/group

Re: CONSTRUCT -

2006-09-03 Thread lazaridis_com
Georg Brandl wrote: > lazaridis_com wrote: > > I would like to fulfill the following task: > > > > The construct: > > > > if __name__ == '__main__': > > > > should be changed to something like: > > > > if identifier.name == '__main__': > > > > The term "identifier" should be selected based on the m

Re: CONSTRUCT -

2006-09-03 Thread Fredrik Lundh
Simon Forman wrote: > I'm sorry, your post makes very little sense. you're somewhat new here, right ? ;-) -- http://mail.python.org/mailman/listinfo/python-list

Re: CONSTRUCT -

2006-09-03 Thread Georg Brandl
lazaridis_com wrote: > I would like to fulfill the following task: > > The construct: > > if __name__ == '__main__': > > should be changed to something like: > > if identifier.name == '__main__': > > The term "identifier" should be selected based on the meaning of the > __double-underscore-enc

Re: CONSTRUCT -

2006-09-02 Thread Simon Forman
lazaridis_com wrote: > I would like to fulfill the following task: > > The construct: > > if __name__ == '__main__': > > should be changed to something like: > > if identifier.name == '__main__': > > The term "identifier" should be selected based on the meaning of the > __double-underscore-enclosur

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-27 Thread Fredrik Lundh
Larry Bates wrote: > 1) Don't call a class instance exec, it will mask the built-in > exec statement. "exec" is a reserved word, and cannot be masked: >>> exec = 10 File "", line 1 exec = 10 ^ SyntaxError: invalid syntax -- http://mail.python.org/mailman/listinfo/python-li

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-27 Thread lazaridis_com
lazaridis_com wrote: > I would like to change the construct: > > if __name__ == '__main__': ... Is there a standard way / naming to wrap "__name__" and other similar attributes to an encapsulating class? Something like e.g.: if mod.name ... or if gbl.name ... - "gbl.newAttribute = value" wo

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-25 Thread lazaridis_com
Larry Bates wrote: > lazaridis_com wrote: > > I would like to change the construct: > > > > if __name__ == '__main__': > > > > to something like: > > > > if exec.isMain(): > > > > My (OO thought) is to place a class in an separate code module and to > > instantiate an singleton instance which would

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-25 Thread lazaridis_com
Duncan Booth wrote: > lazaridis_com wrote: > > > Are ther alternative constructs/mechanism available, which could be > > used to add this functionality possiby directly to a code-module? > > How about something along these lines: > > -- auto.py - > import sys, atexit > > de

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-25 Thread lazaridis_com
Fuzzyman wrote: > lazaridis_com wrote: > > I would like to change the construct: > > > > if __name__ == '__main__': > > > > to something like: > > > > if exec.isMain(): > > > > My (OO thought) is to place a class in an separate code module and to > > instantiate an singleton instance which would ke

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-23 Thread Larry Bates
Georg Brandl wrote: > Larry Bates wrote: >> lazaridis_com wrote: >>> I would like to change the construct: >>> >>> if __name__ == '__main__': >>> >>> to something like: >>> >>> if exec.isMain(): >>> >>> My (OO thought) is to place a class in an separate code module and to >>> instantiate an singlet

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-22 Thread Georg Brandl
Larry Bates wrote: > lazaridis_com wrote: >> I would like to change the construct: >> >> if __name__ == '__main__': >> >> to something like: >> >> if exec.isMain(): >> >> My (OO thought) is to place a class in an separate code module and to >> instantiate an singleton instance which would keep

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-22 Thread Larry Bates
lazaridis_com wrote: > I would like to change the construct: > > if __name__ == '__main__': > > to something like: > > if exec.isMain(): > > My (OO thought) is to place a class in an separate code module and to > instantiate an singleton instance which would keep th something like > this: > >

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-22 Thread Duncan Booth
lazaridis_com wrote: > Are ther alternative constructs/mechanism available, which could be > used to add this functionality possiby directly to a code-module? How about something along these lines: -- auto.py - import sys, atexit def main_body(f): if f.func_globals['

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-22 Thread Fuzzyman
lazaridis_com wrote: > I would like to change the construct: > > if __name__ == '__main__': > > to something like: > > if exec.isMain(): > > My (OO thought) is to place a class in an separate code module and to > instantiate an singleton instance which would keep th something like > this: > > clas

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 >

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-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 bey

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

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 >> servic

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 t

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 wron

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 questio

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: >>

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
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 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, *

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 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: >

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 suppor

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 evolved

Re: Construct raw strings?

2005-09-08 Thread Benji York
Peter Hansen wrote: > Benji York wrote: > >> It's not join that's getting you, it's the non-raw string >> representation in path_to_scan. Use either 'd:\test_images' or >> 'd:\\test_images' instead. > > Benji, you're confusing things: you probably meant r'd:\test_images' > in the above Doh! I

Re: Construct raw strings?

2005-09-07 Thread Terry Reedy
"Thomas W" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I got a stupid problem; on my WinXP-box I want to scan the filesystem > and enter a path to scan like this : > > path_to_scan = 'd:\test_images' I believe you can always use / instead of \ for Win filenames from Python. Av

Re: Construct raw strings?

2005-09-07 Thread Peter Hansen
Benji York wrote: > It's not join that's getting you, it's the non-raw string representation > in path_to_scan. Use either 'd:\test_images' or 'd:\\test_images' instead. Benji, you're confusing things: you probably meant r'd:\test_images' in the above, but in any case I think Robert Kern's on t

Re: Construct raw strings?

2005-09-07 Thread Robert Kern
Thomas W wrote: > I got a stupid problem; on my WinXP-box I want to scan the filesystem > and enter a path to scan like this : > > path_to_scan = 'd:\test_images' path_to_scan = r'd:\test_images' > This is used in a larger context and joined like > > real_path_after_scanning = os.path.join(pat

Re: Construct raw strings?

2005-09-07 Thread Benji York
Thomas W wrote: > I got a stupid problem; on my WinXP-box I want to scan the filesystem > and enter a path to scan like this : > > path_to_scan = 'd:\test_images' Note the lack of an "r" prefix and the \t sequence above. > The problem is that some of the parts being joined contains escape > c