Re: Should NoneType be iterable?
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. > > 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 not iterable'. > > > > (Examples are taken from here > https://rollbar.com/blog/python-typeerror-nonetype-object-is-not-iterable/ > ) > > Example 1: > > mylist = None > > for x in mylist: > > print(x) <== will raise TypeError: 'NoneType' object is not iterable > > Solution: extra If statement > > if mylist is not None: > > for x in mylist: > > print(x) > > > > > > I think Python should handle this case gracefully: if a code would > iterate over None: it should not run any step. but proceed the next > statement. > > > > Has this been discussed or proposed? > > > > Try this instead: > > for x in mylist or (): > > Now a None list will skip iteration entirely, allowing you to get the > effect you want :) > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > I prefer iteration of None to be an error, as in my usage it usually indicates a mistake that I'd want to catch -- https://mail.python.org/mailman/listinfo/python-list
Re: magic-wormhole 0.18.0
On Wed, Mar 12, 2025 at 8:33 PM meejah via Python-list < python-list@python.org> wrote: > Hello, > > I am happy to announce that magic-wormhole 0.18.0 has been released. > A visible change is the default display of QR Codes, following the > specification for file-transfer magic-wormhole codes. > This can be turned off with --no-qr > > All changes in this release: > > * Improve the example to act more like send/receive (#558, @OndrewBot) > * Display a QR code by default for "wormhole send" (#555, @ferada + > @meejah) > This encodes "wormhole-transfer:M-word0-word1" per the spec: > > https://github.com/magic-wormhole/magic-wormhole-protocols/blob/main/uri-scheme.md > * Add sequence diagram > * Support Read the Docs pull-request builds > * Drop support for Python 3.8 (#556) > * Add broken-link checker (#588, https://github.com/Cycloctane) > * Preemptively fix Click 8.2 (#584, @cjwatson) > * Basic support for PEP518 (#579, @SnoopJ) > * Add WORMHOLE_ACCEPT_FILE (#570, @haatveit) > > thanks to all contributors and users, > > meejah > Thanks. When you wish to make announcements like this, please provide context for those who are not following the project. Neal -- https://mail.python.org/mailman/listinfo/python-list