[Tutor] Testing print

Alan Gauld alan.gauld at yahoo.co.uk
Sun Oct 2 04:42:21 EDT 2016


On 02/10/16 02:46, boB Stepp wrote:

>> case. If I know that the result is always an int I can
>> use the first case if I know its always a tuple I can
>> use the second. But not knowing which is just plain
>> messy.
> 
> So in which sorts of scenarios would you use argument unpacking?

Any time a tuple is returned.

The problem I had with your code is that sometimes
you return a string and sometimes a tuple. So I
can only use argument unpacking when I get the tuple.
If I always get a tuple then I can always use unpacking.
Its the mix of incompatible return types that causes
problems.



-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list