This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.snow
Recipients Xiang Gao, benjamin.peterson, christian.heimes, eric.snow, rhettinger
Date 2019-02-06.17:58:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1549475889.0.0.903007147347.issue35914@roundup.psfhosted.org>
In-reply-to
Content
FWIW, if folks *are* checking for tuple (and I'd love to know why) then I'd recommend that they not. :)  A more Pythonic (and arguably generally better) approach would be to stick tightly to what data you need and take advantage of duck-typing.  When possible, try attribute access first if you expect that (e.g. namedtuple or struct seq).  Otherwise try use unpacking.

For example:

```
try:
    x, y = ret.x, ret.y
except AttributeError:
    pass
else:
    ...
```

```
try:
   x, y, _ = ret
except TypeError:
   pass
except ValueError:
   pass
else:
   ...
```

Either way is easier to follow than code that relies on type (and length) checking.  They also have the advantage of allowing arbitrary types that fit (duck-typing).
History
Date User Action Args
2019-02-06 17:58:10eric.snowsetrecipients: + eric.snow, rhettinger, christian.heimes, benjamin.peterson, Xiang Gao
2019-02-06 17:58:08eric.snowsetmessageid: <1549475889.0.0.903007147347.issue35914@roundup.psfhosted.org>
2019-02-06 17:58:08eric.snowlinkissue35914 messages
2019-02-06 17:58:08eric.snowcreate