Re: style question - hasattr

2008-04-08 Thread Miles
On Tue, Apr 8, 2008 at 10:21 PM, ian <[EMAIL PROTECTED]> wrote: > Ok, so what about 'hasattr' ?? > hasattr(myObject,'property') > seems equivalent to > 'property' in dir(myObject) > > I would suggest that using the 'in' is cleaner in this case also. Is > there a performance penalty her

Re: style question - hasattr

2008-04-08 Thread Terry Reedy
"ian" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | In old python code i would use 'has_key' to determine if an element | was present in a dictionary. | | Python 3.0 will even removed 'has_key'. The reason for removal is that | using the 'in' operator is a cleaner syntax and havin

style question - hasattr

2008-04-08 Thread ian
In old python code i would use 'has_key' to determine if an element was present in a dictionary. Python 3.0 will even removed 'has_key'. The reason for removal is that using the 'in' operator is a cleaner syntax and having two ways to achieve the same result is against the principle of the languag