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 __
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
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)
(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
e it behind some pretty
> ## object attributes :)
> ##
> ## YMMV - and don't complain if you don't
> ## like it; I wrote it for ME, not you
> ##
> ## Jordan Callicoat < [EMAIL PROTECTED] >
>
> ## some global methods so we can use them
> ## to set up the clas
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
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
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
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
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
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
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
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
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
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_
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
>>> __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
>>
>> 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
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
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
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
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
"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
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
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
>> 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
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
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
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)
.
http://lazaridis.com
--
http://mail.python.org/mailman/listinfo/python-list
29 matches
Mail list logo