ValueError vs IndexError, unpacking arguments with string.split
Morten W. Petersen
morphex at gmail.com
Fri Nov 30 13:00:17 EST 2018
On Fri, Nov 30, 2018 at 6:21 PM Dan Sommers <
2QdxY4RzWzUUiLuE at potatochowder.com> wrote:
> On 11/30/18 10:57 AM, Morten W. Petersen wrote:
> > On Fri, Nov 30, 2018 at 4:25 PM Dan Sommers
> <2QdxY4RzWzUUiLuE at potatochowder.com> wrote:
> [...]
> > But since you mention it, why is it necessary to ensure a successful
> > operation?
> >
> > Is it so that when
> >
> > a,b,c = [1,2]
> >
> > fails, none of the variables a,b,c have been assigned to, and because
> > of that, one avoids "rolling back" any assignment that would have been
> > done without checking the right-hand argument first ?
>
> That's what I was getting at, but apparently failed to express clearly.
>
> Yes, there are use cases for a short iterator just not assigning the
> rest of the variables, and for a long iterator using only what it needs,
> but also explicit is better than implicit, and errors should never pass
> silently, and other bits of wisdom learned from horrible debugging
> experiences.
>
Aha, yes well you have head, tail, etc.
I guess syntax could be added, so that
a, b, @c = some sequence
would initialize a and b, and leave anything remaining in c. We could
then call this @ syntax "teh snek".
😂
..I guess I haven't punished myself with enough Perl yet.
Regards,
Morten
--
Videos at https://www.youtube.com/user/TheBlogologue
Twittering at http://twitter.com/blogologue
Blogging at http://blogologue.com
Playing music at https://soundcloud.com/morten-w-petersen
Also playing music and podcasting here:
http://www.mixcloud.com/morten-w-petersen/
On Google+ here https://plus.google.com/107781930037068750156
On Instagram at https://instagram.com/morphexx/
More information about the Python-list
mailing list