On 12/16/2011 8:26 PM, Steven D'Aprano wrote:
On Fri, 16 Dec 2011 17:05:57 -0500, Terry Reedy wrote:
It is am important distinction [unbound versus bound]
It is not an important distinction, and I am not confusing the two.
So we agree on the distinction but disagree on its importance.
Let
On Fri, 16 Dec 2011 15:26:30 -0800, Ethan Furman wrote:
> Terry Reedy wrote:
>> On 12/16/2011 4:22 AM, Steven D'Aprano wrote:
[...]
> I think you two are in violent agreement as far as how Python is
> functioning, and the conflict is in the names given to the various
> pieces... I think a glossar
On Fri, 16 Dec 2011 17:05:57 -0500, Terry Reedy wrote:
> On 12/16/2011 4:22 AM, Steven D'Aprano wrote:
>> On Thu, 15 Dec 2011 19:39:17 -0500, Terry Reedy wrote: [...]
>>
>> After reading your post, I think I have worked out where our
>> disagreement lines: you think that bound methods and instance
Ethan Furman wrote:
Terry Reedy wrote:
On 12/16/2011 4:22 AM, Steven D'Aprano wrote:
On Thu, 15 Dec 2011 19:39:17 -0500, Terry Reedy wrote:
[...]
After reading your post, I think I have worked out where our
disagreement
lies: you think that bound methods and instance methods are not the same
Terry Reedy wrote:
On 12/16/2011 4:22 AM, Steven D'Aprano wrote:
On Thu, 15 Dec 2011 19:39:17 -0500, Terry Reedy wrote:
[...]
After reading your post, I think I have worked out where our disagreement
lies: you think that bound methods and instance methods are not the same
thing,
Do you agree
On 12/16/2011 4:22 AM, Steven D'Aprano wrote:
On Thu, 15 Dec 2011 19:39:17 -0500, Terry Reedy wrote:
[...]
After reading your post, I think I have worked out where our disagreement
lines: you think that bound methods and instance methods are not the same
thing,
Do you agree that an unbound met
On Thu, 15 Dec 2011 19:39:17 -0500, Terry Reedy wrote:
[...]
After reading your post, I think I have worked out where our disagreement
lines: you think that bound methods and instance methods are not the same
thing, and that a function defined inside a class is different from a
function outside
On Thu, 15 Dec 2011 05:35:55 -0800, Steve Howell wrote:
> For the special methods like __enter__ and __exit__, the tricky part
> isn't understanding what would happen once the methods were called; the
> tricky part is getting them to be called in the first place, if they
> were not declared inside
On 12/15/2011 12:01 AM, Steven D'Aprano wrote:
On Wed, 14 Dec 2011 18:13:36 -0500, Terry Reedy wrote:
On 12/14/2011 3:01 AM, Steven D'Aprano wrote:
On Wed, 14 Dec 2011 01:29:13 -0500, Terry Reedy wrote:
To complement what Eric says below: The with statement is looking for
an instance *method
MRAB wrote:
To give an analogy, it is like defining mammals as "hairy animals which
give birth to live young", which is correct for all mammals except for
monotremes, which are mammals which lay eggs.
Or the naked mole-rat. Or cetaceans (whales).
The way I understand it, the main characteris
On Dec 14, 9:01 pm, Steven D'Aprano wrote:
> [...]
> So what are methods? In Python, methods are wrappers around functions
> which automatically pass the instance to the inner function object. Under
> normal circumstances, you create methods by declaring functions inside a
> class, but that's not
On Thu, 15 Dec 2011 05:01:21 +, Steven D'Aprano wrote:
>> From the Python glossary:
>> "method: A function which is defined inside a class body."
>>
>> That is actually a bit too narrow, as a function can be added to the
>> class after it is defined. But the point then is that it is treated
On Thu, 15 Dec 2011 05:15:58 +, MRAB wrote:
> On 15/12/2011 05:01, Steven D'Aprano wrote:
>> On Wed, 14 Dec 2011 18:13:36 -0500, Terry Reedy wrote:
>>
>>> On 12/14/2011 3:01 AM, Steven D'Aprano wrote:
On Wed, 14 Dec 2011 01:29:13 -0500, Terry Reedy wrote:
> To complement what
On 15/12/2011 05:01, Steven D'Aprano wrote:
On Wed, 14 Dec 2011 18:13:36 -0500, Terry Reedy wrote:
On 12/14/2011 3:01 AM, Steven D'Aprano wrote:
On Wed, 14 Dec 2011 01:29:13 -0500, Terry Reedy wrote:
To complement what Eric says below: The with statement is looking for
an instance *metho
On Wed, 14 Dec 2011 18:13:36 -0500, Terry Reedy wrote:
> On 12/14/2011 3:01 AM, Steven D'Aprano wrote:
>> On Wed, 14 Dec 2011 01:29:13 -0500, Terry Reedy wrote:
>>
>>> To complement what Eric says below: The with statement is looking for
>>> an instance *method*, which by definition, is a function
On 12/14/2011 3:01 AM, Steven D'Aprano wrote:
On Wed, 14 Dec 2011 01:29:13 -0500, Terry Reedy wrote:
To complement what Eric says below: The with statement is looking for an
instance *method*, which by definition, is a function attribute of a
*class* (the class of the context manager) that take
On Wed, Dec 14, 2011 at 12:14 PM, Lie Ryan wrote:
> On 12/15/2011 03:56 AM, Eric Snow wrote:
>>
>> On Tue, Dec 13, 2011 at 11:05 PM, Eric Snow
>> wrote:
>>
>> If you want to be more dynamic about it you can do it, but it involves
>> black magic. Chances are really good that being explicit throug
On 12/15/2011 03:56 AM, Eric Snow wrote:
On Tue, Dec 13, 2011 at 11:05 PM, Eric Snow wrote:
If you want to be more dynamic about it you can do it, but it involves
black magic. Chances are really good that being explicit through your
class definition is the right approach.
Note that the black
On Dec 14, 12:01 am, Steven D'Aprano wrote:
> [...]
>
> So the normal lookup rules that apply to data attributes, namely
> instance, then class, then superclasses, also applies to methods in
> Python. In languages that don't allow that sort of thing, like Java, you
> need to use convoluted design
On Tue, Dec 13, 2011 at 11:05 PM, Eric Snow wrote:
> On Tue, Dec 13, 2011 at 10:42 PM, Steve Howell wrote:
>> I'm using Python 3.2.2, and the following program gives me an error
>> that I don't understand:
>>
>> class Foo:
>> pass
>>
>> foo = Foo()
>> foo.name = "Steve"
>>
>> def add_goodbye_fun
On Thursday, December 15, 2011 12:08:32 AM UTC+8, 8 Dihedral wrote:
> On Wednesday, December 14, 2011 4:01:24 PM UTC+8, Steven D'Aprano wrote:
> > On Wed, 14 Dec 2011 01:29:13 -0500, Terry Reedy wrote:
> >
> > > To complement what Eric says below: The with statement is looking for an
> > > ins
On Wednesday, December 14, 2011 4:01:24 PM UTC+8, Steven D'Aprano wrote:
> On Wed, 14 Dec 2011 01:29:13 -0500, Terry Reedy wrote:
>
> > To complement what Eric says below: The with statement is looking for an
> > instance *method*, which by definition, is a function attribute of a
> > *class* (the
Steve Howell wrote:
> I'm using Python 3.2.2, and the following program gives me an error
> that I don't understand:
>
> class Foo:
> pass
>
> foo = Foo()
> foo.name = "Steve"
>
> def add_goodbye_function(obj):
> def goodbye():
> print("goodbye " + obj.name)
> obj.goodbye = goodbye
>
On Wed, 14 Dec 2011 01:29:13 -0500, Terry Reedy wrote:
> To complement what Eric says below: The with statement is looking for an
> instance *method*, which by definition, is a function attribute of a
> *class* (the class of the context manager) that takes an instance of the
> class as its first p
On 12/14/2011 1:05 AM, Eric Snow wrote:
On Tue, Dec 13, 2011 at 10:42 PM, Steve Howell wrote:
I'm using Python 3.2.2, and the following program gives me an error
that I don't understand:
class Foo:
pass
foo = Foo()
foo.name = "Steve"
def add_goodbye_function(obj):
def goodbye():
prin
On Tue, Dec 13, 2011 at 10:42 PM, Steve Howell wrote:
> I'm using Python 3.2.2, and the following program gives me an error
> that I don't understand:
>
> class Foo:
> pass
>
> foo = Foo()
> foo.name = "Steve"
>
> def add_goodbye_function(obj):
> def goodbye():
> print("goodbye " + obj.name)
I'm using Python 3.2.2, and the following program gives me an error
that I don't understand:
class Foo:
pass
foo = Foo()
foo.name = "Steve"
def add_goodbye_function(obj):
def goodbye():
print("goodbye " + obj.name)
obj.goodbye = goodbye
add_goodbye_function(foo)
foo.goodbye() # output
27 matches
Mail list logo