On Sat, Jan 26, 2019 at 4:01 PM Steven D'Aprano <steve@pearwood.info> wrote:
On Sat, Jan 26, 2019 at 10:20:11AM -0800, Christopher Barker wrote:


> but, alas, tuple unpacking is apparently automatically disabled for single
> value tuples  (how do you distinguish a tuple with a single value and the
> value itself??)

The time machine strikes again. We have not one but THREE ways of doing
so (although two are alternate ways of spelling the same thing):
py> def func():
...     return [1]

Sure, but this requires that you actually return something "unpackable" from the function. As David Mertz pointed out, functions always return a single value, but that value may or may not be unpackable.

So the OP's desire, that you could extend a function that was originally written returning a single scalar value to instead return multiple values, and have code that expected a single value still work the same simply isn't possible (without other major changes to Python).


Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython