[Python-ideas] iterable.__unpack__ method

Alex Stewart foogod at gmail.com
Mon Feb 25 22:52:32 CET 2013


On Sunday, February 24, 2013 7:09:28 PM UTC-8, Random832 wrote:

>  If you want "smart" unpackable objects, why not allow d in your *d 
> example to be something other than a list?
>
> Like, if you have a,*b = range(1,5); b could literally be range(2,5).
>

Well, primarily for two reasons:

   1. It does not actually do anything to support smart unpackables (i.e. 
   objects that want to be able to produce different values depending on how 
   many items they're asked to produce).  This might be useful for the 
   "infinite iterator" case (and I think somebody proposed it for that 
   earlier), but that's a completely different issue than smart-unpacking..
   2. More importantly, it would almost certainly break some existing code 
   that relies on the fact that the contents of the extended-unpacking-term 
   will always be a list, which would be bad.
   
--Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130225/c6b32d70/attachment.html>


More information about the Python-ideas mailing list