Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > fr.comp.lang.python > #3625
| Path | csiph.com!newsfeed.xs4all.nl!newsfeed9.news.xs4all.nl!2.eu.feeder.erje.net!feeder.erje.net!fdn.fr!news.ortolo.eu!news.izac.org!reader |
|---|---|
| From | Benoit Izac <use.reply.to@INVALID.ADDRESS> |
| Newsgroups | fr.comp.lang.python |
| Subject | Re: Syntaxe pas comprise |
| Date | Thu, 04 Nov 2021 17:30:55 +0100 |
| Message-ID | <87o86zhohs.fsf@izac.org> (permalink) |
| References | <6183d5e8$0$1344$426a74cc@news.free.fr> |
| Reply-To | benoit.izac@free.fr |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| Injection-Info | keg.izac.org; logging-data="406142"; mail-complaints-to="usenet@izac.org" |
| Xref | csiph.com fr.comp.lang.python:3625 |
Show key headers only | View raw
Bonjour, Le 04/11/2021 à 13:45, ast <ast@invalid> a écrit dans le message <6183d5e8$0$1344$426a74cc@news.free.fr> : > Dans cette fonction: > > 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() > > trouvée ici: > > https://www.blog.pythonlibrary.org/2018/06/06/creating-and-manipulating-pdfs-with-pdfrw/ > > je ne comprends pas cette ligne: > > x_increment, y_increment = (scale * i for i in srcpages.xobj_box[2:]) > > (scale * i for i in srcpages.xobj_box[2:]) est un générateur, un seul > objet, on ne devrait pas pouvoir le dérouler dans 2 variables. > > x, y = 1 génère une erreur > x, y = (i for i in range(10)) aussi Mais c'est normal, dans le premier cas il n'y a pas assez d'objets, dans le second il y en a trop. >>> x, y = (i for i in range(2)) >>> x 0 >>> y 1 > mais pas: > > x_increment, y_increment = (scale * i for i in srcpages.xobj_box[2:]) > > pourquoi ? Parce que « srcpages.xobj_box[2:] » contient pile-poil deux éléments. -- Benoit Izac
Back to fr.comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar
Syntaxe pas comprise ast <ast@invalid> - 2021-11-04 13:45 +0100
Re: Syntaxe pas comprise Benoit Izac <use.reply.to@INVALID.ADDRESS> - 2021-11-04 17:30 +0100
Re: Syntaxe pas comprise ast <ast@invalid> - 2021-11-05 10:28 +0100
csiph-web