Re: [sage-devel] Pythonics

2016-04-03 Thread Erik Bray
On Apr 1, 2016 17:07, "Volker Braun" wrote: > > On Friday, April 1, 2016 at 4:19:08 PM UTC+2, Erik Bray wrote: >> >> One of my top wishlist items for Python 4 is some kind of __hasattr__ >> special method for classes and/or an equivalent for descriptors that >> merely

Re: [sage-devel] Pythonics

2016-04-01 Thread Volker Braun
On Friday, April 1, 2016 at 4:19:08 PM UTC+2, Erik Bray wrote: > > One of my top wishlist items for Python 4 is some kind of __hasattr__ > special method for classes and/or an equivalent for descriptors that > merely guarantees* that accessing the attribute of that name will not > result in an

Re: [sage-devel] Pythonics

2016-04-01 Thread Erik Bray
On Thu, Mar 31, 2016 at 11:08 PM, Justin C. Walker wrote: > Hi, all, > > I have couple of questions regarding "attributes" in Python/Sage: > > 1. If hasattr(X, "foo") returns True, does that mean that "X.foo" should not > blow up? Yes, this does, because unfortunately hasattr(X,

Re: [sage-devel] Pythonics

2016-04-01 Thread Harald Schilly
On Friday, April 1, 2016 at 1:24:30 AM UTC+2, Justin C. Walker wrote: > > > Just because a method is callable doesn't mean that it can't raise > > exceptions, including NotImplementedErrors. There's no reasonable way > to > > tell if a method will raise an exception or not without calling

Re: [sage-devel] Pythonics

2016-03-31 Thread Justin C. Walker
On Mar 31, 2016, at 16:15 , David Roe wrote: > On Thu, Mar 31, 2016 at 7:11 PM, Justin C. Walker wrote: > >> >> On Mar 31, 2016, at 15:37 , Vincent Delecroix wrote: >> >>> On 31/03/16 18:22, Johannes wrote: On 31.03.2016 23:08, Justin C. Walker wrote: > 2. Is there a

Re: [sage-devel] Pythonics

2016-03-31 Thread David Roe
On Thu, Mar 31, 2016 at 7:11 PM, Justin C. Walker wrote: > > On Mar 31, 2016, at 15:37 , Vincent Delecroix wrote: > > > On 31/03/16 18:22, Johannes wrote: > >> On 31.03.2016 23:08, Justin C. Walker wrote: > >>> 2. Is there a way to tell, when hasattr(X, "foo") returns True, > >>>

Re: [sage-devel] Pythonics

2016-03-31 Thread Justin C. Walker
On Mar 31, 2016, at 15:37 , Vincent Delecroix wrote: > On 31/03/16 18:22, Johannes wrote: >> On 31.03.2016 23:08, Justin C. Walker wrote: >>> 2. Is there a way to tell, when hasattr(X, "foo") returns True, >>> whether "X.foo" can be called? >> >> X.foo and x.foo.__call__ is None > > !? > >

Re: [sage-devel] Pythonics

2016-03-31 Thread Justin C. Walker
On Mar 31, 2016, at 14:17 , William Stein wrote: > On Thu, Mar 31, 2016 at 2:08 PM, Justin C. Walker wrote: >> Hi, all, >> >> I have couple of questions regarding "attributes" in Python/Sage: >> >> 1. If hasattr(X, "foo") returns True, does that mean that "X.foo" should not

Re: [sage-devel] Pythonics

2016-03-31 Thread Vincent Delecroix
On 31/03/16 18:22, Johannes wrote: On 31.03.2016 23:08, Justin C. Walker wrote: 2. Is there a way to tell, when hasattr(X, "foo") returns True, whether "X.foo" can be called? X.foo and x.foo.__call__ is None !? The only way to go here is if callable(X.foo): print "X.foo is callable"

Re: [sage-devel] Pythonics

2016-03-31 Thread Johannes
On 31.03.2016 23:08, Justin C. Walker wrote: Hi, all, I have couple of questions regarding "attributes" in Python/Sage: 1. If hasattr(X, "foo") returns True, does that mean that "X.foo" should not blow up? this means X.foo is defined. 2. Is there a way to tell, when hasattr(X, "foo")

Re: [sage-devel] Pythonics

2016-03-31 Thread William Stein
On Thu, Mar 31, 2016 at 2:08 PM, Justin C. Walker wrote: > Hi, all, > > I have couple of questions regarding "attributes" in Python/Sage: > > 1. If hasattr(X, "foo") returns True, does that mean that "X.foo" should not > blow up? What's the definition of "blow up"? I think

[sage-devel] Pythonics

2016-03-31 Thread Justin C. Walker
Hi, all, I have couple of questions regarding "attributes" in Python/Sage: 1. If hasattr(X, "foo") returns True, does that mean that "X.foo" should not blow up? 2. Is there a way to tell, when hasattr(X, "foo") returns True, whether "X.foo" can be called? 3. If "X.foo" is callable, is it