Re: [Python-ideas] Restore the __members__ behavior to python3 for C extension writers

2017-06-14 Thread Nick Coghlan
On 15 June 2017 at 11:06, Nathaniel Smith wrote: > On Wed, Jun 14, 2017 at 1:54 PM, Barry Scott wrote: >> > On 13 Jun 2017, at 23:49, Chris Angelico wrote: >> > For that purpose, is it possible to use super().__dir__()? Are there >> > any considerations where that would fail? >> >> Remember that

Re: [Python-ideas] Restore the __members__ behavior to python3 for C extension writers

2017-06-14 Thread Nathaniel Smith
On Wed, Jun 14, 2017 at 1:54 PM, Barry Scott wrote: > > On 13 Jun 2017, at 23:49, Chris Angelico wrote: > > For that purpose, is it possible to use super().__dir__()? Are there > > any considerations where that would fail? > > Remember that I need to do this in the C API and I want default_dir of

Re: [Python-ideas] Restore the __members__ behavior to python3 for C extension writers

2017-06-14 Thread Ethan Furman
On 06/14/2017 01:54 PM, Barry Scott wrote: super().__dir__ looks at the class above me that is typically object() and so is not useful as it does not list the member function from my class or __mro__ or other stuff I may not be aware of that is important to return. __dir__ should return what

Re: [Python-ideas] Restore the __members__ behavior to python3 for C extension writers

2017-06-14 Thread Chris Angelico
On Thu, Jun 15, 2017 at 6:54 AM, Barry Scott wrote: >> class Magic: >>def __getattr__(self, attr): >>if attr in self.generatables: >>return self.generated_value(attr) >>raise AttributeError >>def __dir__(self): >>return default_dir(self) + self.generatab

Re: [Python-ideas] Restore the __members__ behavior to python3 for C extension writers

2017-06-14 Thread Barry Scott
> On 13 Jun 2017, at 23:49, Chris Angelico wrote: > > On Wed, Jun 14, 2017 at 8:09 AM, Terry Reedy wrote: >> Perhaps you are looking for __dir__, called by dir(). >> >> " dir([object]) >> >>Without arguments, return the list of names in the current local scope. >> With an argument, attemp

Re: [Python-ideas] ImportError raised for a circular import

2017-06-14 Thread Stephan Houben
Huh? The semantics of node.js seem to be completely similar to Python in this respect. In both cases the circular import works if you go through the mutable module object but fails if both modules circularly try to import module members directly. Stephan Op 14 jun. 2017 11:17 a.m. schreef "Abdur

Re: [Python-ideas] ImportError raised for a circular import

2017-06-14 Thread Abdur-Rahmaan Janhangeer
anyways circular imports seem to be making people go for node.js rather than using python . . . Abdur-Rahmaan Janhangeer, Mauritius abdurrahmaanjanhangeer.wordpress.com On 13 Jun 2017 23:04, "Barry Scott" wrote: > Recently I fell into the trap of creating a circular import and yet again > it to

Re: [Python-ideas] ImportError raised for a circular import

2017-06-14 Thread Ivan Levkivskyi
On 14 June 2017 at 09:59, Paul Moore wrote: > On 13 June 2017 at 23:36, Chris Angelico wrote: > > On Wed, Jun 14, 2017 at 8:10 AM, Mahmoud Hashemi > wrote: > >> I didn't interpret the initial email as wanting an error on *all* > circular > >> imports. Merely those which are unresolvable. I've d

Re: [Python-ideas] ImportError raised for a circular import

2017-06-14 Thread Paul Moore
On 13 June 2017 at 23:36, Chris Angelico wrote: > On Wed, Jun 14, 2017 at 8:10 AM, Mahmoud Hashemi wrote: >> I didn't interpret the initial email as wanting an error on *all* circular >> imports. Merely those which are unresolvable. I've definitely helped people >> diagnose circular imports and w