Re: [Python-Dev] 'hasattr' is broken by design

2010-08-24 Thread Michael Foord
On 24/08/2010 01:25, Nick Coghlan wrote: On Tue, Aug 24, 2010 at 8:15 AM, Nick Coghlanncogh...@gmail.com wrote: Now, it may be worth considering an addition to the inspect module that was basically: def getattr_static(obj, attr): Retrieve attributes without triggering dynamic lookup via

Re: [Python-Dev] 'hasattr' is broken by design

2010-08-24 Thread Hrvoje Niksic
On 08/23/2010 04:56 PM, Guido van Rossum wrote: On Mon, Aug 23, 2010 at 7:46 AM, Benjamin Petersonbenja...@python.org wrote: 2010/8/23 Yury Selivanovyseliva...@gmail.com: 1) I propose to change 'hasattr' behaviour in Python 3, making it to swallow only AttributeError exceptions (exactly

Re: [Python-Dev] 'hasattr' is broken by design

2010-08-24 Thread Steven D'Aprano
On Tue, 24 Aug 2010 11:09:10 am Guido van Rossum wrote: On Mon, Aug 23, 2010 at 4:56 PM, Steven D'Aprano st...@pearwood.info wrote: [...] I have always thought that hasattr() does what it says on the box: it tests for the *existence* of an attribute, that is, one that statically exists

Re: [Python-Dev] 'hasattr' is broken by design

2010-08-24 Thread Benjamin Peterson
2010/8/24 Hrvoje Niksic hrvoje.nik...@avl.com: The __length_hint__ lookup expects either no exception or AttributeError, and will propagate others.  I'm not sure if this is a bug.  On the one hand, throwing anything except AttributeError from __getattr__ is bad style (which is why we fixed the

Re: [Python-Dev] 'hasattr' is broken by design

2010-08-24 Thread Benjamin Peterson
2010/8/24 Hrvoje Niksic hrvoje.nik...@avl.com: On 08/24/2010 02:31 PM, Benjamin Peterson wrote: 2010/8/24 Hrvoje Niksichrvoje.nik...@avl.com:  The __length_hint__ lookup expects either no exception or AttributeError,  and will propagate others.  I'm not sure if this is a bug.  On the one

Re: [Python-Dev] 'hasattr' is broken by design

2010-08-24 Thread P.J. Eby
At 03:37 PM 8/24/2010 +0200, Hrvoje Niksic wrote: a) a business case of throwing anything other than AttributeError from __getattr__ and friends is almost certainly a bug waiting to happen, and FYI, best practice for __getattr__ is generally to bail with an AttributeError as soon as you see

Re: [Python-Dev] 'hasattr' is broken by design

2010-08-24 Thread Benjamin Peterson
2010/8/24 P.J. Eby p...@telecommunity.com: At 03:37 PM 8/24/2010 +0200, Hrvoje Niksic wrote: a) a business case of throwing anything other than AttributeError from __getattr__ and friends is almost certainly a bug waiting to happen, and FYI, best practice for __getattr__ is generally to bail

Re: [Python-Dev] 'hasattr' is broken by design

2010-08-24 Thread Steve Holden
On 8/24/2010 9:45 AM, Benjamin Peterson wrote: 2010/8/24 Hrvoje Niksic hrvoje.nik...@avl.com: On 08/24/2010 02:31 PM, Benjamin Peterson wrote: 2010/8/24 Hrvoje Niksichrvoje.nik...@avl.com: The __length_hint__ lookup expects either no exception or AttributeError, and will propagate

Re: [Python-Dev] 'hasattr' is broken by design

2010-08-24 Thread Guido van Rossum
On Tue, Aug 24, 2010 at 4:51 AM, Steven D'Aprano st...@pearwood.info wrote: But that's the thing... as far as I am concerned, a dynamically defined attribute *doesn't* exist. If it existed, __getattr__ would never be called. A minor semantic difference, to be sure, but it's real to me. Eh? If

Re: [Python-Dev] 'hasattr' is broken by design

2010-08-24 Thread R. David Murray
On Tue, 24 Aug 2010 09:26:09 -0500, Benjamin Peterson benja...@python.org wrote: 2010/8/24 P.J. Eby p...@telecommunity.com: At 03:37 PM 8/24/2010 +0200, Hrvoje Niksic wrote: a) a business case of throwing anything other than AttributeError from __getattr__ and friends is almost certainly

Re: [Python-Dev] 'hasattr' is broken by design

2010-08-24 Thread Benjamin Peterson
2010/8/24 R. David Murray rdmur...@bitdance.com: On Tue, 24 Aug 2010 09:26:09 -0500, Benjamin Peterson benja...@python.org wrote: 2010/8/24 P.J. Eby p...@telecommunity.com: At 03:37 PM 8/24/2010 +0200, Hrvoje Niksic wrote: a) a business case of throwing anything other than AttributeError

Re: [Python-Dev] 'hasattr' is broken by design

2010-08-24 Thread James Y Knight
On Aug 24, 2010, at 10:26 AM, Benjamin Peterson wrote: 2010/8/24 P.J. Eby p...@telecommunity.com: At 03:37 PM 8/24/2010 +0200, Hrvoje Niksic wrote: a) a business case of throwing anything other than AttributeError from __getattr__ and friends is almost certainly a bug waiting to happen,

Re: [Python-Dev] 'hasattr' is broken by design

2010-08-24 Thread Benjamin Peterson
2010/8/24 James Y Knight f...@fuhm.net: On Aug 24, 2010, at 10:26 AM, Benjamin Peterson wrote: 2010/8/24 P.J. Eby p...@telecommunity.com: At 03:37 PM 8/24/2010 +0200, Hrvoje Niksic wrote: a) a business case of throwing anything other than AttributeError from __getattr__ and friends is

Re: [Python-Dev] 'hasattr' is broken by design

2010-08-24 Thread P.J. Eby
At 10:13 AM 8/24/2010 -0500, Benjamin Peterson wrote: 2010/8/24 James Y Knight f...@fuhm.net: On Aug 24, 2010, at 10:26 AM, Benjamin Peterson wrote: 2010/8/24 P.J. Eby p...@telecommunity.com: At 03:37 PM 8/24/2010 +0200, Hrvoje Niksic wrote: a) a business case of throwing anything other

[Python-Dev] Generating canonical argument call from `getargspec` and `getcallargs` results

2010-08-24 Thread cool-RR
I was happy to see the new `getcallargs` function in the `inspect` module. But there's one thing I want to do that's related to it, and maybe this was implemented somewhere or someone can give me some pointers about it. I want to have a function that takes the results of `getargspec` and

Re: [Python-Dev] 'hasattr' is broken by design

2010-08-24 Thread Glyph Lefkowitz
On Aug 24, 2010, at 8:31 AM, Benjamin Peterson wrote: 2010/8/24 Hrvoje Niksic hrvoje.nik...@avl.com: The __length_hint__ lookup expects either no exception or AttributeError, and will propagate others. I'm not sure if this is a bug. On the one hand, throwing anything except AttributeError

[Python-Dev] Released: Python 2.6.6

2010-08-24 Thread Barry Warsaw
Hello fellow Pythoneers and Pythonistas, I'm very happy to announce the release of Python 2.6.6. A truly impressive number of bugs have been fixed since Python 2.6.5. Source code and Windows installers for Python 2.6.6 are now available here: http://www.python.org/download/releases/2.6.6/

Re: [Python-Dev] Python-Dev Digest, Vol 85, Issue 71

2010-08-24 Thread John Nagle
On 8/24/2010 12:40 AM, python-dev-requ...@python.org wrote: Message: 4 Date: Mon, 23 Aug 2010 17:21:50 -0700 From: Brett Cannon br...@python.org It is also non-obvious to any beginner. Are we really going to want to propagate the knowledge of this trick as a fundamental idiom? I would rather

Re: [Python-Dev] Released: Python 2.6.6

2010-08-24 Thread Raymond Hettinger
On Aug 24, 2010, at 12:31 PM, Barry Warsaw wrote: Hello fellow Pythoneers and Pythonistas, I'm very happy to announce the release of Python 2.6.6. Thanks Barry :-) Raymond ___ Python-Dev mailing list Python-Dev@python.org

Re: [Python-Dev] Released: Python 2.6.6

2010-08-24 Thread Barry Warsaw
On Aug 24, 2010, at 03:31 PM, Barry Warsaw wrote: Python 2.6.6 marks the end of regular maintenance releases for the Python 2.6 series. From now until October 2013, only security related, source-only releases of Python 2.6 will be made available. After that date, Python 2.6 will no longer be

Re: [Python-Dev] 'hasattr' is broken by design

2010-08-24 Thread Greg Ewing
Steven D'Aprano wrote: But that's the thing... as far as I am concerned, a dynamically defined attribute *doesn't* exist. Maybe for your particular use case, but the concept of whether an attribute is dynamically defined or not is not well-defined in general. Consider an object that is

Re: [Python-Dev] Released: Python 2.6.6

2010-08-24 Thread Victor Stinner
Le mercredi 25 août 2010 01:12:40, Barry Warsaw a écrit : merwok asks on IRC whether documentation changes to release26-maint will be allowed. I can sympathize with the 'allow' argument; Python 2.6 is still either the default version or soon to be the new default in several distributions, and