AttributeError in "with" statement (3.2.2)
Ethan Furman
ethan at stoneleaf.us
Fri Dec 16 19:34:49 EST 2011
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
>>> thing,
>>
>> Do you agree that an unbound method and a bound method are different?
>> In Python, as indicated by the glossary entry, an unspecified 'method'
>> is usually meant to be an unbound method.
>
> 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 glossary would help (please correct me):
>
> function: callable code suite
>
> method: function that lives in a class
>
> unbound method: function that lives in a class
>
> bound method: callable wrapper around function that has been extracted
> from class that will supply the instance object to the function (note:
> Python does not save these, they are recreated at each lookup)
I think the above 'bound method' definition should be attributed to
Terry, and Steven's follows:
bound method: callable wrapper around any function that will accept an
instance object as the first parameter, and the wrapper will supply said
instance object when calling the function (and where/how function was
created is irrelevent, as is where the wrapper is stored)
>
>
> and here is where I think you two diverge:
>
> instance method (Steven): a bound method that has been saved into the
> instance __dict__ (no matter how created)
>
> instance method (Terry): a function that must be looked up in the class
>
>
> Have I missed anything?
>
> Honestly-trying-learn-the-distinctions-ly yours,
>
> ~Ethan~
More information about the Python-list
mailing list