Re: ValueError vs IndexError, unpacking arguments with string.split

2018-11-30 Thread Chris Angelico
On Sat, Dec 1, 2018 at 10:55 AM Morten W. Petersen wrote: > But this raises the question of how to write Python code, > short and sweet, that could handle infinite iterators in > such an unpack with multiple variables to assign to. > > Which I guess is mostly theoretical, as there are other > ways

Re: ValueError vs IndexError, unpacking arguments with string.split

2018-11-30 Thread Morten W. Petersen
On Sat, Dec 1, 2018 at 12:25 AM Chris Angelico wrote: > On Sat, Dec 1, 2018 at 10:18 AM Morten W. Petersen > wrote: > > > > On Fri, Nov 30, 2018 at 7:25 PM Dan Sommers < > > 2qdxy4rzwzuui...@potatochowder.com> wrote: > > > > > On 11/30/18 12:00 PM, Morten W. Petersen wrote: > > > > > > > I gues

Re: multiple JSON documents in one file, change proposal

2018-11-30 Thread Thomas Jollans
On 30/11/2018 23:40, Marko Rauhamaa wrote: > Paul Rubin : >> Maybe someone can convince me I'm misusing JSON but I often want to >> write out a file containing multiple records, and it's convenient to >> use JSON to represent the record data. >> >> The obvious way to read a JSON doc from a file is

Re: ValueError vs IndexError, unpacking arguments with string.split

2018-11-30 Thread Chris Angelico
On Sat, Dec 1, 2018 at 10:18 AM Morten W. Petersen wrote: > > On Fri, Nov 30, 2018 at 7:25 PM Dan Sommers < > 2qdxy4rzwzuui...@potatochowder.com> wrote: > > > On 11/30/18 12:00 PM, Morten W. Petersen wrote: > > > > > I guess syntax could be added, so that > > > > > > a, b, @c = some sequence >

Re: ValueError vs IndexError, unpacking arguments with string.split

2018-11-30 Thread Morten W. Petersen
On Fri, Nov 30, 2018 at 7:25 PM Dan Sommers < 2qdxy4rzwzuui...@potatochowder.com> wrote: > On 11/30/18 12:00 PM, Morten W. Petersen wrote: > > > 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 cou

Re: multiple JSON documents in one file, change proposal

2018-11-30 Thread Chris Angelico
On Sat, Dec 1, 2018 at 9:46 AM Marko Rauhamaa wrote: > > Paul Rubin : > > Maybe someone can convince me I'm misusing JSON but I often want to > > write out a file containing multiple records, and it's convenient to > > use JSON to represent the record data. > > > > The obvious way to read a JSON d

Re: multiple JSON documents in one file, change proposal

2018-11-30 Thread Cameron Simpson
On 01Dec2018 00:40, Marko Rauhamaa wrote: Paul Rubin : Maybe someone can convince me I'm misusing JSON but I often want to write out a file containing multiple records, and it's convenient to use JSON to represent the record data. The obvious way to read a JSON doc from a file is with "json.lo

Re: multiple JSON documents in one file, change proposal

2018-11-30 Thread Marko Rauhamaa
Paul Rubin : > Maybe someone can convince me I'm misusing JSON but I often want to > write out a file containing multiple records, and it's convenient to > use JSON to represent the record data. > > The obvious way to read a JSON doc from a file is with "json.load(f)" > where f is a file handle. Un

Re: RAR functionality

2018-11-30 Thread Chris Angelico
On Sat, Dec 1, 2018 at 8:43 AM Benjamin Schollnick wrote: > > Folks, > > Can anyone explain to me why RAR support isn’t available natively in python? > > We have the zipfile and tarfile modules… > > Yes, there is rarfile and PaTools but they both rely on RAR being available > to shell out to… > W

Re: RAR functionality

2018-11-30 Thread Wildman via Python-list
On Fri, 30 Nov 2018 16:42:06 -0500, Benjamin Schollnick wrote: > Folks, > > Can anyone explain to me why RAR support isn’t available natively in python? > > We have the zipfile and tarfile modules… > > Yes, there is rarfile and PaTools but they both rely on RAR being available > to shell out

RAR functionality

2018-11-30 Thread Benjamin Schollnick
Folks, Can anyone explain to me why RAR support isn’t available natively in python? We have the zipfile and tarfile modules… Yes, there is rarfile and PaTools but they both rely on RAR being available to shell out to… What is it about RAR files that makes it unreasonable to handle in nativel

Re: ValueError vs IndexError, unpacking arguments with string.split

2018-11-30 Thread Dan Sommers
On 11/30/18 12:00 PM, Morten W. Petersen wrote: > 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". Close. ;-) Try this: a, b, *c = [4, 5, 6, 7] -- https://ma

Re: ValueError vs IndexError, unpacking arguments with string.split

2018-11-30 Thread Morten W. Petersen
On Fri, Nov 30, 2018 at 6:21 PM Dan Sommers < 2qdxy4rzwzuui...@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 > <2qdxy4rzwzuui...@potatochowder.com> wrote: > [...] > > But since you mention it, why is it necessary to en

Re: ValueError vs IndexError, unpacking arguments with string.split

2018-11-30 Thread Dan Sommers
On 11/30/18 10:57 AM, Morten W. Petersen wrote: > On Fri, Nov 30, 2018 at 4:25 PM Dan Sommers <2qdxy4rzwzuui...@potatochowder.com> wrote: >> Python validates that the right hand side contains exactly the right >> number of elements before beginning to unpack, presumably to ensure a >> successfu

Re: ValueError vs IndexError, unpacking arguments with string.split

2018-11-30 Thread Morten W. Petersen
On Fri, Nov 30, 2018 at 4:25 PM Dan Sommers < 2qdxy4rzwzuui...@potatochowder.com> wrote: > On 11/30/18 7:35 AM, Morten W. Petersen wrote: > > > ... but isn't it logical that the > > string is parsed and split, and then later the unpacking operation fails > > with an IndexError? > > With slightly s

Re: ValueError vs IndexError, unpacking arguments with string.split

2018-11-30 Thread Dan Sommers
On 11/30/18 7:35 AM, Morten W. Petersen wrote: ... but isn't it logical that the string is parsed and split, and then later the unpacking operation fails with an IndexError? With slightly simpler code and the full text of the exception, the details becomes more apparent: >>> x, y = [4] Traceb

Re: ValueError vs IndexError, unpacking arguments with string.split

2018-11-30 Thread Morten W. Petersen
On Fri, Nov 30, 2018 at 4:02 PM Peter Otten <__pete...@web.de> wrote: > Morten W. Petersen wrote: > > > I've been reading up on a bit of C++, Assembler etc. lately, so maybe my > > mind expected an IndexError because of that, but isn't it logical that > the > > string is parsed and split, and the

Re: ValueError vs IndexError, unpacking arguments with string.split

2018-11-30 Thread Peter Otten
Morten W. Petersen wrote: > Hi there. > > I was adding a port specification feature to my surveil project as shown > here: > > https://github.com/morphex/surveil/commit/703318f87c4c450a37944b565a10718ef27b57b4 > > A bit later I was surprised when the script raised an exception, and that > I ha

ValueError vs IndexError, unpacking arguments with string.split

2018-11-30 Thread Morten W. Petersen
Hi there. I was adding a port specification feature to my surveil project as shown here: https://github.com/morphex/surveil/commit/703318f87c4c450a37944b565a10718ef27b57b4 A bit later I was surprised when the script raised an exception, and that I had to catch a ValueError instead of an IndexErr