Re: Should NoneType be iterable?

2023-06-20 Thread Cameron Simpson via Python-list
On 21Jun2023 10:09, Chris Angelico wrote: On Wed, 21 Jun 2023 at 09:59, Cameron Simpson via Python-list wrote: I wasted some time the other evening on an API which returned a string or None. My own API, and the pain it caused tells me that that API design choice isn't good (it's an automatic

Re: Should NoneType be iterable?

2023-06-20 Thread Chris Angelico via Python-list
On Wed, 21 Jun 2023 at 09:59, Cameron Simpson via Python-list wrote: > I wasted some time the other evening on an API which returned a string > or None. My own API, and the pain it caused tells me that that API > design choice isn't good (it's an automatic attribute based on a tag, > returning

Re: Should NoneType be iterable?

2023-06-20 Thread Cameron Simpson via Python-list
On 21Jun2023 03:01, Greg Ewing wrote: On 20/06/23 7:36 pm, Barry wrote: I have some APIs that do return None or a list. The None says that a list is not available and that the caller is responsible with dealing in a application-domain specific with with that situation. In that case, the

Re: Should NoneType be iterable?

2023-06-20 Thread Chris Angelico via Python-list
On Wed, 21 Jun 2023 at 03:46, Igor Berger via Python-list wrote: > Most of the regulars in this list/group read the posts using the mailing list > and > have declared that they explicitly filter out anything posted on Google > Groups. > > I've seen it multiple times with your posts. You respond

Re: Should NoneType be iterable?

2023-06-20 Thread Roel Schroeven via Python-list
Op 20/06/2023 om 2:50 schreef Greg Ewing via Python-list: I would question the wisdom of designing an API that can return either a sequence or None. If it normally returns a sequence, and there are no items to return, it should return an empty sequence. I guess it depends on the reason why there

Re: Should NoneType be iterable?

2023-06-20 Thread Igor Berger via Python-list
On Monday, June 19, 2023 at 4:11:15 PM UTC-4, Julio Di Egidio wrote: > On Monday, 19 June 2023 at 21:58:21 UTC+2, dn wrote: > > On 20/06/2023 06.12, Neal Becker via Python-list wrote: > > > > I prefer iteration of None to be an error, as in my usage it usually > > > indicates a mistake that

Re: Should NoneType be iterable?

2023-06-20 Thread Greg Ewing via Python-list
On 20/06/23 7:36 pm, Barry wrote: I have some APIs that do return None or a list. The None says that a list is not available and that the caller is responsible with dealing in a application-domain specific with with that situation. In that case, the caller should probably be checking for None

Re: Should NoneType be iterable?

2023-06-20 Thread Barry via Python-list
> On 20 Jun 2023, at 01:57, Greg Ewing via Python-list > wrote: > > I would question the wisdom of designing an API that > can return either a sequence or None. I have some APIs that do return None or a list. The None says that a list is not available and that the caller is responsible with

Re: Should NoneType be iterable?

2023-06-19 Thread Greg Ewing via Python-list
I would question the wisdom of designing an API that can return either a sequence or None. If it normally returns a sequence, and there are no items to return, it should return an empty sequence. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Should NoneType be iterable?

2023-06-19 Thread dn via Python-list
On 20/06/2023 06.12, Neal Becker via Python-list wrote: On Mon, Jun 19, 2023 at 12:42 PM Chris Angelico via Python-list < python-list@python.org> wrote: On Tue, 20 Jun 2023 at 02:37, Peter Bona via Python-list wrote: Hi I am wondering if there has been any discussion why NoneType is not

Re: Should NoneType be iterable?

2023-06-19 Thread Neal Becker via Python-list
On Mon, Jun 19, 2023 at 12:42 PM Chris Angelico via Python-list < python-list@python.org> wrote: > On Tue, 20 Jun 2023 at 02:37, Peter Bona via Python-list > wrote: > > > > Hi > > > > I am wondering if there has been any discussion why NoneType is not > iterable My feeling is that it should be.

Re: Should NoneType be iterable?

2023-06-19 Thread Chris Angelico via Python-list
On Tue, 20 Jun 2023 at 02:37, Peter Bona via Python-list wrote: > > Hi > > I am wondering if there has been any discussion why NoneType is not iterable > My feeling is that it should be. > Sometimes I am using API calls which return None. > If there is a return value (which is iterable) I am

Should NoneType be iterable?

2023-06-19 Thread Peter Bona via Python-list
Hi I am wondering if there has been any discussion why NoneType is not iterable My feeling is that it should be. Sometimes I am using API calls which return None. If there is a return value (which is iterable) I am using a for loop to iterate. Now I am getting 'TypeError: 'NoneType' object is