On Jun 24, 12:40 pm, John Henry <[EMAIL PROTECTED]> wrote:
> On Jun 24, 1:19 am, John Henry <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Jun 23, 6:24 pm, Steven D'Aprano
>
> > <[EMAIL PROTECTED]> wrote:
> > > On Sat, 23 Jun 2007 12:31:39 -0700, John Henry wrote:
> > > > it works fine but PythonCard isn'
On Jun 24, 1:19 am, John Henry <[EMAIL PROTECTED]> wrote:
> On Jun 23, 6:24 pm, Steven D'Aprano
>
> <[EMAIL PROTECTED]> wrote:
> > On Sat, 23 Jun 2007 12:31:39 -0700, John Henry wrote:
> > > it works fine but PythonCard isn't calling this function when I
> > > clicked on the button.
>
> > I think y
On Jun 23, 6:24 pm, Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> On Sat, 23 Jun 2007 12:31:39 -0700, John Henry wrote:
> > it works fine but PythonCard isn't calling this function when I
> > clicked on the button.
>
> I think you need to take this question onto a PythonCard list. I have no
> idea h
On Sat, 23 Jun 2007 12:31:39 -0700, John Henry wrote:
> it works fine but PythonCard isn't calling this function when I
> clicked on the button.
I think you need to take this question onto a PythonCard list. I have no
idea how PythonCard decides which method to call.
--
Steven.
--
http://ma
On Jun 23, 10:56 am, Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> On Sat, 23 Jun 2007 09:06:36 -0700, John Henry wrote:
>
> >> > But then how do I create the on_Button1_mouseClick function?
>
> >> That depends on what it is supposed to do, but in general you want a
> >> factory function -- a functi
On Jun 23, 10:56 am, Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> On Sat, 23 Jun 2007 09:06:36 -0700, John Henry wrote:
>
> >> > But then how do I create the on_Button1_mouseClick function?
>
> >> That depends on what it is supposed to do, but in general you want a
> >> factory function -- a functi
On Sat, 23 Jun 2007 09:06:36 -0700, John Henry wrote:
>>
>> > But then how do I create the on_Button1_mouseClick function?
>>
>> That depends on what it is supposed to do, but in general you want a
>> factory function -- a function that returns functions. Here's a simple
>> example:
>>
>
>
> Ste
>
> > But then how do I create the on_Button1_mouseClick function?
>
> That depends on what it is supposed to do, but in general you want a
> factory function -- a function that returns functions. Here's a simple
> example:
>
Steven,
May be I didn't explain it clearly: the PythonCard package exp
On Sat, 23 Jun 2007 00:02:09 -0700, John Henry wrote:
[snip]
> Notice that the event handler for mouseClick to Button1 is done via
> the function on_Button1_mouseClick. This is very simple and works
> great - until you try to create the button on the fly.
>
> Creating the button itself is no pro
On Jun 22, 7:36 pm, Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> On Fri, 22 Jun 2007 14:44:54 -0700, John Henry wrote:
> > The above doesn't exactly do I what need. I was looking for a way to
> > add method to a class at run time.
>
> > What does work, is to define an entire sub-class at run time.
On Fri, 22 Jun 2007 14:44:54 -0700, John Henry wrote:
> The above doesn't exactly do I what need. I was looking for a way to
> add method to a class at run time.
>
> What does work, is to define an entire sub-class at run time. Like:
>
> class DummyParent:
> def __init__(self):
> r
John Henry wrote:
> Hi list,
>
> I have a need to create class methods on the fly. For example, if I
> do:
>
> class Dummy:
> def __init__(self):
> exec '''def method_dynamic(self):\n\treturn
> self.method_static("it's me")'''
> return
>
> def method_static(self, text):
7stud wrote:
> On Jun 22, 3:23 pm, askel <[EMAIL PROTECTED]> wrote:
>
>>sorry, of course last line should be:
>>Dummy().method2('Hello, world!')
>
>
> ..which doesn't meet the op's requirements.
>
Which were contradictory.
--
http://mail.python.org/mailman/listinfo/python-list
On Jun 22, 2:44 pm, John Henry <[EMAIL PROTECTED]> wrote:
> On Jun 22, 2:28 pm, askel <[EMAIL PROTECTED]> wrote:
>
(snipped)
>
> The above doesn't exactly do I what need. I was looking for a way to
> add method to a class at run time.
I'm not sure what you mean by this. Bind an attribute -- a
On Jun 22, 2:28 pm, askel <[EMAIL PROTECTED]> wrote:
> On Jun 22, 5:17 pm, 7stud <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Jun 22, 2:24 pm, askel <[EMAIL PROTECTED]> wrote:
>
> > > class Dummy:
> > > def method(self, arg):
> > > print arg
>
> > > def method2(self, arg):
> > > self.method(arg)
On Jun 22, 5:17 pm, 7stud <[EMAIL PROTECTED]> wrote:
> On Jun 22, 2:24 pm, askel <[EMAIL PROTECTED]> wrote:
>
> > class Dummy:
> > def method(self, arg):
> > print arg
>
> > def method2(self, arg):
> > self.method(arg)
>
> > Dummy.method2 = method2
> > Dummy.method2('Hello, world!')
>
> Tra
On Jun 22, 3:23 pm, askel <[EMAIL PROTECTED]> wrote:
> sorry, of course last line should be:
> Dummy().method2('Hello, world!')
..which doesn't meet the op's requirements.
--
http://mail.python.org/mailman/listinfo/python-list
On Jun 22, 5:17 pm, 7stud <[EMAIL PROTECTED]> wrote:
> On Jun 22, 2:24 pm, askel <[EMAIL PROTECTED]> wrote:
>
> > class Dummy:
> > def method(self, arg):
> > print arg
>
> > def method2(self, arg):
> > self.method(arg)
>
> > Dummy.method2 = method2
> > Dummy.method2('Hello, world!')
>
> Tra
On Jun 22, 2:24 pm, askel <[EMAIL PROTECTED]> wrote:
> class Dummy:
> def method(self, arg):
> print arg
>
> def method2(self, arg):
> self.method(arg)
>
> Dummy.method2 = method2
> Dummy.method2('Hello, world!')
Traceback (most recent call last):
File "test1.py", line 8, in ?
Dummy.
On Jun 22, 3:02 pm, John Henry <[EMAIL PROTECTED]> wrote:
> Hi list,
>
> I have a need to create class methods on the fly. For example, if I
> do:
>
> class Dummy:
> def __init__(self):
> exec '''def method_dynamic(self):\n\treturn
> self.method_static("it's me")'''
> return
>
Found a message on the web that says I need to use setattr to add the
method to the class at run time. But how do I do that?
Regards,
On Jun 22, 12:02 pm, John Henry <[EMAIL PROTECTED]> wrote:
> Hi list,
>
> I have a need to create class methods on the fly. For example, if I
> do:
>
> class Dum
Hi list,
I have a need to create class methods on the fly. For example, if I
do:
class Dummy:
def __init__(self):
exec '''def method_dynamic(self):\n\treturn
self.method_static("it's me")'''
return
def method_static(self, text):
print text
return
I like
22 matches
Mail list logo