A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2013-July/127239.html below:

[Python-Dev] lament for the demise of unbound methods

[Python-Dev] lament for the demise of unbound methodsChris Withers chris at simplistix.co.uk
Sun Jul 7 08:40:01 CEST 2013
On 05/07/2013 11:26, "Martin v. Löwis" wrote:
> ...
>>>> A.__getattribute__(A,'s')
> <staticmethod object at 0x100937828>
>>>> A.__getattribute__(A,'c')
> <classmethod object at 0x100937860>
>>>> A.__getattribute__(A,'r')
> <function A.r at 0x100938378>

Okay, but with this line:

found = found.__getattribute__(found, n)

I get a tonne of failures like this:

       File "<doctest 
testfixtures.tests.test_replacer.TestReplacer.test_with_statement[3]>", 
line 2, in <module>
         r.replace('testfixtures.tests.sample1.z',test_z)
       File 
"/Users/chris/LocalGIT/testfixtures/testfixtures/replace.py", line 50, 
in replace
         container, method, attribute, t_obj = resolve(target)
       File 
"/Users/chris/LocalGIT/testfixtures/testfixtures/resolve.py", line 17, 
in resolve
         found = found.__getattribute__(found, n)
     TypeError: expected 1 arguments, got 2

If I change it to :

found = found.__getattribute__(n)

I get fewer failures, but still plenty, now of the form:

       File "<doctest 
testfixtures.tests.test_replacer.TestReplacer.test_multiple_replace[7]>", line 
1, in <module>
         r.replace('testfixtures.tests.sample1.X.y',test_y)
       File 
"/Users/chris/LocalGIT/testfixtures/testfixtures/replace.py", line 50, 
in replace
         container, method, attribute, t_obj = resolve(target)
       File 
"/Users/chris/LocalGIT/testfixtures/testfixtures/resolve.py", line 17, 
in resolve
         found = found.__getattribute__(n)
     TypeError: expected 1 arguments, got 0

...so I'm back to:

found = found.__dict__[n]

...and having to catch both KeyError and AttributeError.

Chris

-- 
Simplistix - Content Management, Batch Processing & Python Consulting
             - http://www.simplistix.co.uk
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4