Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

fortune: No such file or directory


devel / comp.lang.python / Syntax not understood

SubjectAuthor
* Syntax not understoodast
+* Re: Syntax not understoodStefan Ram
|`- Re: Syntax not understoodast
+- Re: Syntax not understoodDavid Lowry-Duda
+- Re: Syntax not understood2QdxY4RzWzUUiLuE
+- Re: Syntax not understoodChris Angelico
+- Re: Syntax not understood2QdxY4RzWzUUiLuE
`- Re: Syntax not understoodChris Angelico

1
Syntax not understood

<6183c75c$0$29473$426a74cc@news.free.fr>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=15907&group=comp.lang.python#15907

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.nntp4.net!news.gegeweb.eu!gegeweb.org!usenet-fr.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!cleanfeed1-b.proxad.net!nnrp1-1.free.fr!not-for-mail
Date: Thu, 4 Nov 2021 12:43:23 +0100
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101
Thunderbird/91.2.1
Newsgroups: comp.lang.python
Content-Language: fr
From: ast...@invalid (ast)
Subject: Syntax not understood
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 33
Message-ID: <6183c75c$0$29473$426a74cc@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 04 Nov 2021 12:43:24 CET
NNTP-Posting-Host: 91.170.32.5
X-Trace: 1636026204 news-2.free.fr 29473 91.170.32.5:14898
X-Complaints-To: abuse@proxad.net
 by: ast - Thu, 4 Nov 2021 11:43 UTC

Hello

In this function

def get4(srcpages):
scale = 0.5
srcpages = PageMerge() + srcpages
x_increment, y_increment = (scale * i for i in srcpages.xobj_box[2:])
for i, page in enumerate(srcpages):
page.scale(scale)
page.x = x_increment if i & 1 else 0
page.y = 0 if i & 2 else y_increment
return srcpages.render()

found here

https://www.blog.pythonlibrary.org/2018/06/06/creating-and-manipulating-pdfs-with-pdfrw/

I do not understand this line:

x_increment, y_increment = (scale * i for i in srcpages.xobj_box[2:])

(scale * i for i in srcpages.xobj_box[2:]) is a generator, a single
object, it should not be possible to unpack it into 2 variables.

x, y = 1 generates an error
x, y = (i for i in range(10)) too

but not

x_increment, y_increment = (scale * i for i in srcpages.xobj_box[2:])

why ?

Re: Syntax not understood

<assignment-20211104164019@ram.dialup.fu-berlin.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=15910&group=comp.lang.python#15910

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Syntax not understood
Date: 4 Nov 2021 15:41:47 GMT
Organization: Stefan Ram
Lines: 22
Expires: 1 Dec 2021 11:59:58 GMT
Message-ID: <assignment-20211104164019@ram.dialup.fu-berlin.de>
References: <6183c75c$0$29473$426a74cc@news.free.fr>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de X2KNJe2MzNtU+O+ht7Pw1QVNfXh5o1gmLCx6z0BQ9l0YR1
X-Copyright: (C) Copyright 2021 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Thu, 4 Nov 2021 15:41 UTC

ast <ast@invalid> writes:
>(scale * i for i in srcpages.xobj_box[2:]) is a generator, a single
>object, it should not be possible to unpack it into 2 variables.

But the value of the right-hand side /always/ is a single object!

A syntax of an assignment statement that has been simplified
by me but is sufficient for this post is:

target list = source expression

. The evaluation of the source expression yields an object.

If the target list is not a single target, that object must
be an iterable with the same number of items as there are targets
in the target list, and the items are assigned, from left to
right, to the corresponding targets.

A generator object /is/ an iterable, and, here, it apparently
yields exactly two items.

Re: Syntax not understood

<618405b5$0$4998$426a34cc@news.free.fr>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=15911&group=comp.lang.python#15911

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!paganini.bofh.team!weretis.net!feeder8.news.weretis.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!cleanfeed2-a.proxad.net!nnrp1-1.free.fr!not-for-mail
Date: Thu, 4 Nov 2021 17:09:24 +0100
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101
Thunderbird/91.3.0
Subject: Re: Syntax not understood
Content-Language: fr
Newsgroups: comp.lang.python
References: <6183c75c$0$29473$426a74cc@news.free.fr>
<assignment-20211104164019@ram.dialup.fu-berlin.de>
From: ast...@invalid (ast)
In-Reply-To: <assignment-20211104164019@ram.dialup.fu-berlin.de>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 31
Message-ID: <618405b5$0$4998$426a34cc@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 04 Nov 2021 17:09:25 CET
NNTP-Posting-Host: 91.170.32.5
X-Trace: 1636042165 news-4.free.fr 4998 91.170.32.5:7877
X-Complaints-To: abuse@proxad.net
 by: ast - Thu, 4 Nov 2021 16:09 UTC

Le 04/11/2021 à 16:41, Stefan Ram a écrit :
> ast <ast@invalid> writes:
>> (scale * i for i in srcpages.xobj_box[2:]) is a generator, a single
>> object, it should not be possible to unpack it into 2 variables.
>
> But the value of the right-hand side /always/ is a single object!
>
> A syntax of an assignment statement that has been simplified
> by me but is sufficient for this post is:
>
> target list = source expression
>
> . The evaluation of the source expression yields an object.
>
> If the target list is not a single target, that object must
> be an iterable with the same number of items as there are targets
> in the target list, and the items are assigned, from left to
> right, to the corresponding targets.
>
> A generator object /is/ an iterable, and, here, it apparently
> yields exactly two items.
>
>

understood

It is like:

x, y = (i for i in range(2))

thx

Re: Syntax not understood

<mailman.175.1636051496.23718.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=15912&group=comp.lang.python#15912

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: dav...@lowryduda.com (David Lowry-Duda)
Newsgroups: comp.lang.python
Subject: Re: Syntax not understood
Date: Thu, 4 Nov 2021 14:36:48 -0400
Lines: 15
Message-ID: <mailman.175.1636051496.23718.python-list@python.org>
References: <6183c75c$0$29473$426a74cc@news.free.fr>
<YYQoQJEB1qTa/k7j@icerm-dld>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.uni-berlin.de 25tKc2XLTGD9rRCxorHjiQoYl9gzrsWH54IAaaHY4mYg==
Return-Path: <david@lowryduda.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="1024-bit key; unprotected key"
header.d=lowryduda.com header.i=@lowryduda.com header.b=BE51mXwa;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.051
X-Spam-Evidence: '*H*': 0.90; '*S*': 0.00; 'example.': 0.09; 'prints':
0.09; 'subject:not': 0.09; 'object,': 0.16; 'subject:Syntax':
0.16; 'values': 0.17; 'to:addr:python-list': 0.20; 'code': 0.23;
'header:In-Reply-To:1': 0.34; 'using': 0.37; 'this.': 0.37;
'single': 0.39; 'exact': 0.40; 'received:98': 0.40; 'should':
0.40; 'skip:o 10': 0.61; 'here': 0.62; 'received:23.106': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lowryduda.com;
s=dkim; t=1636051011;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
in-reply-to:in-reply-to:references:references;
bh=MSUhO9yoAjueOtDKp5MbnardpaZJoYA+8DUR1NncHbs=;
b=BE51mXwazeRPNoOvxZDCK03tlMuBqPyuJtDNfdbWrYk7vwFW9H5/GhV6m3REgbapBG+MXD
LAxd7tArFci5vGDP1VfvAViqv+8q/NUK/54cUYzfoL8M71jU/MB9UALh4+vInVlN1eWpGl
IeiE6QAV+M0/O+/uBOeaIWmlBg/Eut4=
Mail-Followup-To: python-list@python.org
Content-Disposition: inline
In-Reply-To: <6183c75c$0$29473$426a74cc@news.free.fr>
X-Spam-Status: No, score=0.25
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.35
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <YYQoQJEB1qTa/k7j@icerm-dld>
X-Mailman-Original-References: <6183c75c$0$29473$426a74cc@news.free.fr>
 by: David Lowry-Duda - Thu, 4 Nov 2021 18:36 UTC

> x_increment, y_increment = (scale * i for i in srcpages.xobj_box[2:])
>
> (scale * i for i in srcpages.xobj_box[2:]) is a generator, a single
> object, it should not be possible to unpack it into 2 variables.

If you know the exact number of values in the generator, you can do
this. Here is an oversimplified example.

l = [0, 1, 2, 3, 4, 5]
a, b = (elem * 10 for elem in l[:4])
print(a, b) # prints 40 50

This is very fragile code and I would recommend against using it.

- DLD

Re: Syntax not understood

<mailman.176.1636053732.23718.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=15913&group=comp.lang.python#15913

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: 2QdxY4Rz...@potatochowder.com
Newsgroups: comp.lang.python
Subject: Re: Syntax not understood
Date: Thu, 4 Nov 2021 12:21:58 -0700
Lines: 39
Message-ID: <mailman.176.1636053732.23718.python-list@python.org>
References: <6183c75c$0$29473$426a74cc@news.free.fr>
<YYQoQJEB1qTa/k7j@icerm-dld> <YYQy1sEOudjiA2oH@scrozzle>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.uni-berlin.de dsnE1daRTvWByxachuuKfQKSUvMnAdW1yns1UTyKIkzw==
Return-Path: <2QdxY4RzWzUUiLuE@potatochowder.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.007
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'that?': 0.07; 'depend':
0.09; 'else:': 0.09; 'example.': 0.09; 'prints': 0.09;
'received:78': 0.09; 'subject:not': 0.09;
'from:addr:2qdxy4rzwzuuilue': 0.16; 'from:addr:potatochowder.com':
0.16; 'hand,': 0.16; 'message-id:@scrozzle': 0.16; 'object,':
0.16; 'received:136.243': 0.16; 'received:78.46': 0.16;
'received:78.46.172': 0.16; 'received:www458.your-server.de':
0.16; 'received:your-server.de': 0.16; 'subject:Syntax': 0.16;
'values,': 0.16; 'wrote:': 0.16; 'values': 0.17; 'to:addr:python-
list': 0.20; 'code': 0.23; 'received:de': 0.23; 'depends': 0.25;
'raise': 0.31; 'from,': 0.32; 'received:136': 0.32; "didn't":
0.34; 'header:In-Reply-To:1': 0.34; 'definitely': 0.35; 'yes,':
0.35; 'following': 0.35; 'using': 0.37; "it's": 0.37; 'this.':
0.37; 'single': 0.39; 'exact': 0.40; 'should': 0.40; 'skip:o 10':
0.61; 'here': 0.62; 'between': 0.63; 'came': 0.65; 'generator':
0.69; 'documented': 0.76; 'known': 0.84; 'origin,': 0.84;
'quantity': 0.84; 'remainder': 0.84; 'surround': 0.84
Mail-Followup-To: python-list@python.org
Content-Disposition: inline
In-Reply-To: <YYQoQJEB1qTa/k7j@icerm-dld>
X-Authenticated-Sender: 2QdxY4RzWzUUiLuE@potatochowder.com
X-Virus-Scanned: Clear (ClamAV 0.103.3/26343/Thu Nov 4 09:22:31 2021)
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.35
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <YYQy1sEOudjiA2oH@scrozzle>
X-Mailman-Original-References: <6183c75c$0$29473$426a74cc@news.free.fr>
<YYQoQJEB1qTa/k7j@icerm-dld>
 by: 2QdxY4Rz...@potatochowder.com - Thu, 4 Nov 2021 19:21 UTC

On 2021-11-04 at 14:36:48 -0400,
David Lowry-Duda <david@lowryduda.com> wrote:

> > x_increment, y_increment = (scale * i for i in srcpages.xobj_box[2:])
> >
> > (scale * i for i in srcpages.xobj_box[2:]) is a generator, a single
> > object, it should not be possible to unpack it into 2 variables.
>
> If you know the exact number of values in the generator, you can do
> this. Here is an oversimplified example.
>
> l = [0, 1, 2, 3, 4, 5]
> a, b = (elem * 10 for elem in l[:4])
> print(a, b) # prints 40 50
>
> This is very fragile code and I would recommend against using it.

How is that any more fragile than any other operation that destructs (or
doesn't) a tuple?

Is the following fragile:

quotient, remainder = divmod(numerator, denominator)

Would you surround it with try/except, or always unpack it defensively?

result = divmod(numerator, denominator)
if len(result) == 2:
quotient, remainder = result
else:
raise SomeException("divmod didn't work")

If I know where a generator (or an iterator, or a tuple, or a list) came
from, and it's documented to contain/yield a known quantity of values,
then why is it fragile to depend on that?

On the other hand, yes, if I build code that depends on a lot of
unstated relationships between values of questionable (or unknown)
origin, then I am definitely asking for trouble.

Re: Syntax not understood

<mailman.177.1636054127.23718.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=15914&group=comp.lang.python#15914

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: Syntax not understood
Date: Fri, 5 Nov 2021 06:28:34 +1100
Lines: 36
Message-ID: <mailman.177.1636054127.23718.python-list@python.org>
References: <6183c75c$0$29473$426a74cc@news.free.fr>
<YYQoQJEB1qTa/k7j@icerm-dld> <YYQy1sEOudjiA2oH@scrozzle>
<CAPTjJmqzrj494GQ=L_8S6DR3Gcjdc7=ObNkUtJJdJ2PTvbopCQ@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de Uy1CRtAAxDvkjY8Iy18bawdrL7se5k+Ond6iQyu/kujA==
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=FHEHsvHA;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.025
X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'example.': 0.09; 'prints':
0.09; 'subject:not': 0.09; 'syntax': 0.15; 'assuming': 0.16;
'chrisa': 0.16; 'elements.': 0.16; 'from:addr:rosuav': 0.16;
'from:name:chris angelico': 0.16; 'length:': 0.16; 'object,':
0.16; 'opinion,': 0.16; 'subject:Syntax': 0.16; 'wrote:': 0.16;
'says': 0.17; 'values': 0.17; 'to:addr:python-list': 0.20;
'input': 0.21; 'fri,': 0.22; 'code': 0.23; 'to:name:python': 0.32;
'message-id:@mail.gmail.com': 0.32; 'but': 0.32; 'header:In-Reply-
To:1': 0.34; 'received:google.com': 0.34; 'from:addr:gmail.com':
0.35; 'using': 0.37; "it's": 0.37; 'received:209.85': 0.37;
'this.': 0.37; 'received:209': 0.39; 'two': 0.39; 'single': 0.39;
'exact': 0.40; 'should': 0.40; 'four': 0.60; 'initial': 0.61;
'skip:o 10': 0.61; 'here': 0.62; 'clear': 0.64; 'less': 0.65;
'exactly': 0.68; '2021': 0.71; 'little': 0.73; 'removal': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=4d6P4AXeZ48kTSOSunG1vOjysAb8BSdDF1JGx2rrwiI=;
b=FHEHsvHAyjmUUrVdobnZ1zVpGdfu1rXdqtaEfhIJvCRnGod8UGvGlDVIkpn00zybmW
aE11mBKuFPjpMWbBCEiZMV4BCKxGE7Bg+FiRz/dtpwVMU2cAN3JlxCxDI5eJFKB0lIfP
Yh6JHQt6MgDE02Gr7foAIhqWz4waJFcfhQozhrQrnSwuxtzhu2TG09Bk3jksnBVYlzT9
RaaLluucZgVEXkTKShZdXTrzzXp60szTRGESJ9Xfp5RMoxt09NWSp5luDy5/zdGoYxMC
hyMGbQvYYUAqUesMLZ+IZ0kcFup/g1+iJakeq85ap7zMSOGzd7zovfJJc3AHHV0A9/ul
7NXw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=4d6P4AXeZ48kTSOSunG1vOjysAb8BSdDF1JGx2rrwiI=;
b=J7ROqr310U8D+PsMZZOn6ha7aZ6hZ/9tEz4tEbeBNyQTVntaIxxGsMUnO2HuQ5pstN
SmpAhLHDHuYzgyR2/Q0NrvlPR/12eJmot1Tf5n+CURW4wYAUqgcLUGv3YPAah6xNbZiC
yQHmdieybfj86tnPvYYvyl5u9EDumnz4Ndg55zne3eOa2X6sGvDNd+cam2H26DmBhDKg
gvuUQxeuMqjQPheZLgrQoi+aCt7n7k+aYrnvyu6TwWCByCDyuMXfYYnVERtigU6TzMsy
lybQ8w90jWswlnolglWRaYJCM9qP7hxCbrtEvy5bqkIE5Gzk4tfWew03nOit7LucAWZz
BHoA==
X-Gm-Message-State: AOAM530UttBsxebFeJzgmTdIClX9MIPSGA8rQqvqltnlGtt6PF8ynDdy
KOiOd1BnpBIXYbbRTZ3ACd4P+VQZ/OkzBhknw2OamdnciKg=
X-Google-Smtp-Source: ABdhPJxXza+1Hr1OAGnzvFJfeqKeyvzjPH0CHvrpV8GHHbD5rfLNUIZmkLHFbcgARHnrHUM+PsHHKfeXVg7l0rnuZck=
X-Received: by 2002:a7b:c92e:: with SMTP id h14mr10884063wml.135.1636054125473;
Thu, 04 Nov 2021 12:28:45 -0700 (PDT)
In-Reply-To: <YYQy1sEOudjiA2oH@scrozzle>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.35
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAPTjJmqzrj494GQ=L_8S6DR3Gcjdc7=ObNkUtJJdJ2PTvbopCQ@mail.gmail.com>
X-Mailman-Original-References: <6183c75c$0$29473$426a74cc@news.free.fr>
<YYQoQJEB1qTa/k7j@icerm-dld>
<YYQy1sEOudjiA2oH@scrozzle>
 by: Chris Angelico - Thu, 4 Nov 2021 19:28 UTC

On Fri, Nov 5, 2021 at 6:23 AM <2QdxY4RzWzUUiLuE@potatochowder.com> wrote:
>
> On 2021-11-04 at 14:36:48 -0400,
> David Lowry-Duda <david@lowryduda.com> wrote:
>
> > > x_increment, y_increment = (scale * i for i in srcpages.xobj_box[2:])
> > >
> > > (scale * i for i in srcpages.xobj_box[2:]) is a generator, a single
> > > object, it should not be possible to unpack it into 2 variables.
> >
> > If you know the exact number of values in the generator, you can do
> > this. Here is an oversimplified example.
> >
> > l = [0, 1, 2, 3, 4, 5]
> > a, b = (elem * 10 for elem in l[:4])
> > print(a, b) # prints 40 50
> >
> > This is very fragile code and I would recommend against using it.
>
> How is that any more fragile than any other operation that destructs (or
> doesn't) a tuple?
>

The only part that's fragile, in my opinion, is (from the initial
post) that it's using removal syntax to slice off some, which is
fragile against the original input length:

x_increment, y_increment = (scale * i for i in srcpages.xobj_box[2:])

But since it says "box", I would start by assuming that it has four
elements. (They might be x1,y1,x2,y2 or x,y,w,h but it'll almost
always be four.) So it's not TOO fragile, when working with boxes, but
it is a little less clear that thing[2:] will always give exactly two
results.

ChrisA

Re: Syntax not understood

<mailman.178.1636055067.23718.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=15915&group=comp.lang.python#15915

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: 2QdxY4Rz...@potatochowder.com
Newsgroups: comp.lang.python
Subject: Re: Syntax not understood
Date: Thu, 4 Nov 2021 12:44:20 -0700
Lines: 46
Message-ID: <mailman.178.1636055067.23718.python-list@python.org>
References: <6183c75c$0$29473$426a74cc@news.free.fr>
<YYQoQJEB1qTa/k7j@icerm-dld> <YYQy1sEOudjiA2oH@scrozzle>
<CAPTjJmqzrj494GQ=L_8S6DR3Gcjdc7=ObNkUtJJdJ2PTvbopCQ@mail.gmail.com>
<YYQ4FMqkD4xwW3Qw@scrozzle>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.uni-berlin.de tcPxUOFJWznRPBcBSd8FYAcLeSPSyXa97W68A4TpRiwA==
Return-Path: <2QdxY4RzWzUUiLuE@potatochowder.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.002
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; ':-)': 0.09; 'angelico':
0.09; 'example.': 0.09; 'prints': 0.09; 'received:78': 0.09;
'subject:not': 0.09; 'syntax': 0.15; '+1100,': 0.16; 'assuming':
0.16; 'elements.': 0.16; 'from:addr:2qdxy4rzwzuuilue': 0.16;
'from:addr:potatochowder.com': 0.16; 'length:': 0.16; 'message-
id:@scrozzle': 0.16; 'object,': 0.16; 'opinion,': 0.16; 'posters':
0.16; 'received:136.243': 0.16; 'received:78.46': 0.16;
'received:78.46.172': 0.16; 'received:78.46.172.2': 0.16;
'received:sslproxy05.your-server.de': 0.16; 'received:www458.your-
server.de': 0.16; 'received:your-server.de': 0.16; 'slicing':
0.16; 'subject:Syntax': 0.16; 'wrote:': 0.16; 'says': 0.17;
'values': 0.17; 'to:addr:python-list': 0.20; 'input': 0.21;
'fri,': 0.22; 'code': 0.23; 'received:de': 0.23; 'saying': 0.25;
'leave': 0.27; 'chris': 0.28; 'context': 0.32; 'received:136':
0.32; 'but': 0.32; 'mailing': 0.33; 'header:In-Reply-To:1': 0.34;
'missing': 0.37; 'using': 0.37; "it's": 0.37; 'this.': 0.37;
'two': 0.39; 'single': 0.39; 'list': 0.39; 'exact': 0.40;
'should': 0.40; 'four': 0.60; 'initial': 0.61; 'skip:o 10': 0.61;
'here': 0.62; 'clear': 0.64; 'less': 0.65; 'exactly': 0.68;
'2021': 0.71; 'little': 0.73; 'skip:y 10': 0.76; 'life': 0.77;
'disagree': 0.84; 'elements,': 0.84; 'removal': 0.91
Mail-Followup-To: python-list@python.org
Content-Disposition: inline
In-Reply-To: <CAPTjJmqzrj494GQ=L_8S6DR3Gcjdc7=ObNkUtJJdJ2PTvbopCQ@mail.gmail.com>
X-Authenticated-Sender: 2QdxY4RzWzUUiLuE@potatochowder.com
X-Virus-Scanned: Clear (ClamAV 0.103.3/26343/Thu Nov 4 09:22:31 2021)
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.35
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <YYQ4FMqkD4xwW3Qw@scrozzle>
X-Mailman-Original-References: <6183c75c$0$29473$426a74cc@news.free.fr>
<YYQoQJEB1qTa/k7j@icerm-dld>
<YYQy1sEOudjiA2oH@scrozzle>
<CAPTjJmqzrj494GQ=L_8S6DR3Gcjdc7=ObNkUtJJdJ2PTvbopCQ@mail.gmail.com>
 by: 2QdxY4Rz...@potatochowder.com - Thu, 4 Nov 2021 19:44 UTC

On 2021-11-05 at 06:28:34 +1100,
Chris Angelico <rosuav@gmail.com> wrote:

> On Fri, Nov 5, 2021 at 6:23 AM <2QdxY4RzWzUUiLuE@potatochowder.com> wrote:
> >
> > On 2021-11-04 at 14:36:48 -0400,
> > David Lowry-Duda <david@lowryduda.com> wrote:
> >
> > > > x_increment, y_increment = (scale * i for i in srcpages.xobj_box[2:])
> > > >
> > > > (scale * i for i in srcpages.xobj_box[2:]) is a generator, a single
> > > > object, it should not be possible to unpack it into 2 variables.
> > >
> > > If you know the exact number of values in the generator, you can do
> > > this. Here is an oversimplified example.
> > >
> > > l = [0, 1, 2, 3, 4, 5]
> > > a, b = (elem * 10 for elem in l[:4])
> > > print(a, b) # prints 40 50
> > >
> > > This is very fragile code and I would recommend against using it.
> >
> > How is that any more fragile than any other operation that destructs (or
> > doesn't) a tuple?
> >
>
> The only part that's fragile, in my opinion, is (from the initial
> post) that it's using removal syntax to slice off some, which is
> fragile against the original input length:
>
> x_increment, y_increment = (scale * i for i in srcpages.xobj_box[2:])
>
> But since it says "box", I would start by assuming that it has four
> elements. (They might be x1,y1,x2,y2 or x,y,w,h but it'll almost
> always be four.) So it's not TOO fragile, when working with boxes, but
> it is a little less clear that thing[2:] will always give exactly two
> results.

I won't disagree that most boxes are going to be described by four
elements, in which case slicing off the first two *should* leave two
more (presumably x_increment and y_increment).

So if you're saying that all that's missing is a description of
srcpages.xobj_box, then I agree. :-) But such is life on a mailing
list where posters don't always give their questions the context they
deserve.

Re: Syntax not understood

<mailman.179.1636056153.23718.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=15916&group=comp.lang.python#15916

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: Syntax not understood
Date: Fri, 5 Nov 2021 07:02:20 +1100
Lines: 27
Message-ID: <mailman.179.1636056153.23718.python-list@python.org>
References: <6183c75c$0$29473$426a74cc@news.free.fr>
<YYQoQJEB1qTa/k7j@icerm-dld> <YYQy1sEOudjiA2oH@scrozzle>
<CAPTjJmqzrj494GQ=L_8S6DR3Gcjdc7=ObNkUtJJdJ2PTvbopCQ@mail.gmail.com>
<YYQ4FMqkD4xwW3Qw@scrozzle>
<CAPTjJmo0uBvTZzxdox5C4t6zF+e6fhnFhx=b+6rwD1RD7qDKZQ@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de iyvEur3nxCQcJp/JKdPk4w1d7K5qjKScy0C2NxI9KQxg==
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=PNFPGRSE;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.076
X-Spam-Evidence: '*H*': 0.85; '*S*': 0.00; ':-)': 0.09; 'subject:not':
0.09; '(unless': 0.16; 'assuming': 0.16; 'chrisa': 0.16;
'elements.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris
angelico': 0.16; 'indeed': 0.16; "it'd": 0.16; 'posters': 0.16;
'slicing': 0.16; 'subject:Syntax': 0.16; 'wrote:': 0.16; 'python':
0.16; 'says': 0.17; "aren't": 0.19; 'to:addr:python-list': 0.20;
'input': 0.21; 'fri,': 0.22; 'code': 0.23; 'saying': 0.25;
"isn't": 0.27; 'leave': 0.27; 'context': 0.32; 'to:name:python':
0.32; 'message-id:@mail.gmail.com': 0.32; 'but': 0.32; 'mailing':
0.33; 'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'from:addr:gmail.com': 0.35; 'missing': 0.37; "it's": 0.37;
'received:209.85': 0.37; 'received:209': 0.39; 'two': 0.39;
'list': 0.39; 'four': 0.60; 'experienced': 0.61; 'clear': 0.64;
'less': 0.65; 'that,': 0.67; 'exactly': 0.68; 'dimensions': 0.69;
'obvious': 0.69; '2021': 0.71; 'little': 0.73; 'skip:y 10': 0.76;
'life': 0.77; 'disagree': 0.84; 'elements,': 0.84; 'exactly.':
0.84; 'minor': 0.84; 'spell': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=dcWvoHWIV9yqtTSCUKdWk5YcgcY7ToUj9vDLCwXbCpU=;
b=PNFPGRSEyeGLDP9C+esG3yu7q+lffJxnDeDuGiqdEXGctucgjNjbxcuLKucl84+hdA
+Kd3O90GwokoCT8eVvXKcEnqz3E7+YNAeehzTNaJdCBJrdumbbvvU4IZ/t/zBlJgf/GL
2fFXYqpbHIXJwWk72R1VKUwBXlpfjhH0+/iBGhyL1RXpombmxQ/N6m2dc7xG0BbWA+jO
Q23CXie/eQXOBRF6s4LdQMPxuc/42xsSsUaF8EudMD64G3j9YezxpunmTjPz/J3e0iKd
BEwwh12q7xwoBFXaFfr9YZ6i90QgDKzjYpPiTh0cA0zriNnXa0KyHSAiICnuCCWEaEOL
5yeg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=dcWvoHWIV9yqtTSCUKdWk5YcgcY7ToUj9vDLCwXbCpU=;
b=IDs1D+WjS+bqIDp3OgWZjY6rBdZgj4ZxbaW5jM1QOOY07C8qrHy/1qVmARWKGOIlFl
4/n8RxKAw9o01LpB9gMncQLzKu6QLsI9vPHhT+vb5dBxieE9tLZskGLK/LvwqAwCRvAs
Yc7pW5iXpps/p65RdmUTFDDPwmR8cJLTV39HDOQ30kV1rYiLeddthk34yhNdrqAKgctV
ELXKDrNrwHxE+8R6e9OXvOpfa/8kY4xqodwz4OcJrBFUFGIa7vLLNDoK89Ra+xvrQ2jO
06QB4/7gitBpY/mL85JMYTWcsR8DvNiRCp5UQ6BeuFT7wWmDXaRUAH+itxjK8EiekmhX
t3yQ==
X-Gm-Message-State: AOAM5338tLnlhu6I2t18rqSEs6iHoiOdb8w8fpy3CVZVJZgmaNnKovWj
CmmFQrdDxlSOKSlgoFWqDq8VuN7hJfqnwUhuptgpxcrw
X-Google-Smtp-Source: ABdhPJxb9BwaHop6Sio3g+0ork5OSQ0QoJ9jgVDB4qtXFpca7ofc1hXoEYqkuA0DqSOYdDx0VTnwL+wiI9g5qThcbYI=
X-Received: by 2002:adf:fc90:: with SMTP id g16mr57471751wrr.53.1636056150964;
Thu, 04 Nov 2021 13:02:30 -0700 (PDT)
In-Reply-To: <YYQ4FMqkD4xwW3Qw@scrozzle>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.35
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAPTjJmo0uBvTZzxdox5C4t6zF+e6fhnFhx=b+6rwD1RD7qDKZQ@mail.gmail.com>
X-Mailman-Original-References: <6183c75c$0$29473$426a74cc@news.free.fr>
<YYQoQJEB1qTa/k7j@icerm-dld>
<YYQy1sEOudjiA2oH@scrozzle>
<CAPTjJmqzrj494GQ=L_8S6DR3Gcjdc7=ObNkUtJJdJ2PTvbopCQ@mail.gmail.com>
<YYQ4FMqkD4xwW3Qw@scrozzle>
 by: Chris Angelico - Thu, 4 Nov 2021 20:02 UTC

On Fri, Nov 5, 2021 at 6:45 AM <2QdxY4RzWzUUiLuE@potatochowder.com> wrote:
> > But since it says "box", I would start by assuming that it has four
> > elements. (They might be x1,y1,x2,y2 or x,y,w,h but it'll almost
> > always be four.) So it's not TOO fragile, when working with boxes, but
> > it is a little less clear that thing[2:] will always give exactly two
> > results.
>
> I won't disagree that most boxes are going to be described by four
> elements, in which case slicing off the first two *should* leave two
> more (presumably x_increment and y_increment).

Exactly. To an experienced Python programmer, it's obvious that that
line of code is scaling the dimensions and assigning them. But if you
aren't comfortable with that, then it isn't so obvious.

Perhaps it'd be better to spell it as [-2:], which will clearly give
two results regardless of the length of the input (unless it's too
short). But that's minor IMO.

> So if you're saying that all that's missing is a description of
> srcpages.xobj_box, then I agree. :-) But such is life on a mailing
> list where posters don't always give their questions the context they
> deserve.

Indeed :)

ChrisA

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor