Syntax not understood

Chris Angelico rosuav at gmail.com
Thu Nov 4 16:02:20 EDT 2021


On Fri, Nov 5, 2021 at 6:45 AM <2QdxY4RzWzUUiLuE at 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


More information about the Python-list mailing list