Re: How Python works: What do you know about support for negative indices?

2010-09-13 Thread Raymond Hettinger
On Sep 10, 2:13 pm, Terry Reedy wrote: > Reading the third paragraph out of context, one can miss the restriction > to built-in objects. I had assumed that the conversion using len(), when > available, happened prior to the __getitem__ call. Yes, that's a common misconception. It is probably ba

Re: How Python works: What do you know about support for negative indices?

2010-09-13 Thread Raymond Hettinger
[Ben Finney] > I encourage anyone whose messages are munged like that to seek > correction from their mail service provider, and switch to a different > one until it's fixed. The post was typed on a mobile device into the text window on Google Groups. It's too bad that inane concerns with newline

Re: How Python works: What do you know about support for negative indices?

2010-09-12 Thread Aahz
In article <87r5gz93sv@benfinney.id.au>, Ben Finney wrote: >Neil Hodgson writes: >> >> There appear to be deliberate wraps at sentence end or automatic wraps >> to fit <80 columns. > >The automatic wraps in the code presented in the message are wrong. The >automatic wraps in the bullet point

Re: How Python works: What do you know about support for negative indices?

2010-09-11 Thread Ben Finney
Neil Hodgson writes: > There appear to be deliberate wraps at sentence end or automatic wraps > to fit <80 columns. The automatic wraps in the code presented in the message are wrong. The automatic wraps in the bullet point list are, if not wrong, at least presumably unintended. I hope that cle

Re: How Python works: What do you know about support for negative indices?

2010-09-11 Thread Cameron Simpson
On 10Sep2010 12:46, Daniel Fetchinson wrote: | > Raymond Hettinger writes: | >> It doesn't seem to be common knowledge when and how a[x] gets | >> translated to a[x+len(x)]. So, here's a short info post on how Python | >> supports negative indices for sequences. | > | > Thanks for this. Could yo

Re: How Python works: What do you know about support for negative indices?

2010-09-11 Thread Neil Hodgson
Ben Finney: > For those who think the problem may be with the recipient's software, I > see the same annoying line-wrapping problems in the archived message > http://mail.python.org/pipermail/python-list/2010-September/1255167.html>. That looks well-formatted to me and just the same as I see i

Re: How Python works: What do you know about support for negative indices?

2010-09-11 Thread Aahz
In article <87vd6d84f7@benfinney.id.au>, Ben Finney wrote: >Ben Finney writes: >> Raymond Hettinger writes: >>> >>> It doesn't seem to be common knowledge when and how a[x] gets >>> translated to a[x+len(x)]. So, here's a short info post on how >>> Python supports negative indices for seque

Re: How Python works: What do you know about support for negative indices?

2010-09-10 Thread Ben Finney
Ben Finney writes: > Raymond Hettinger writes: > > > It doesn't seem to be common knowledge when and how a[x] gets > > translated to a[x+len(x)]. So, here's a short info post on how > > Python supports negative indices for sequences. > > Thanks for this. Could you post your messages using a chan

Re: How Python works: What do you know about support for negative indices?

2010-09-10 Thread Aahz
In article , Daniel Fetchinson wrote: >Attribution missing: >> >> I encourage anyone whose messages are munged like that to seek >> correction from their mail service provider, and switch to a different >> one until it's fixed. > >I encourage anyone who has problems with reading various emails, >

Re: How Python works: What do you know about support for negative indices?

2010-09-10 Thread Terry Reedy
On 9/9/2010 9:37 PM, Raymond Hettinger wrote: The docs guarantee that Python's builtin sequences implement support for negative indices ( http://docs.python.org/dev/reference/expressions.html#subscriptions The relevant paragraphs are " For built-in objects, there are two types of objects that

Re: How Python works: What do you know about support for negative indices?

2010-09-10 Thread Daniel Fetchinson
> Raymond Hettinger writes: > >> It doesn't seem to be common knowledge when and how a[x] gets >> translated to a[x+len(x)]. So, here's a short info post on how Python >> supports negative indices for sequences. > > Thanks for this. Could you post your messages using a channel that > doesn't arbi

Re: How Python works: What do you know about support for negative indices?

2010-09-10 Thread Steven D'Aprano
On Thu, 09 Sep 2010 18:37:49 -0700, Raymond Hettinger wrote: > Hello Folks. > > It doesn't seem to be common knowledge when and how a[x] gets translated > to a[x+len(x)]. So, here's a short info post on how Python supports > negative indices for sequences. [...] > Hope you all found this to be i

Re: How Python works: What do you know about support for negative indices?

2010-09-10 Thread Giacomo Boffi
Ben Finney writes: > Raymond Hettinger writes: > >> It doesn't seem to be common knowledge when and how a[x] gets >> translated to a[x+len(x)]. So, here's a short info post on how Python >> supports negative indices for sequences. > > Thanks for this. Could you post your messages using a channe

Re: How Python works: What do you know about support for negative indices?

2010-09-10 Thread Ulrich Eckhardt
Raymond Hettinger wrote: > collections.deque('abcde').__getitem__[-2] # extension class, magic > method Small nit: You don't mean [square] brackets here, right? Otherwise, good posting, thank you! Uli -- Sator Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932 -- h

Re: How Python works: What do you know about support for negativeindices?

2010-09-09 Thread Neil Hodgson
Mark Tolonen: > It came across fine for me (on much maligned Outlook Express, no less). Yes, looks fine to me both in Thunderbird (news, not mailing list) and at Google Groups. There is a single text part with all lines except an URL easily within 80 columns. Perhaps there is a problem in Ben'

Re: How Python works: What do you know about support for negativeindices?

2010-09-09 Thread Mark Tolonen
"Ben Finney" wrote in message news:874ody9w3v@benfinney.id.au... Raymond Hettinger writes: It doesn't seem to be common knowledge when and how a[x] gets translated to a[x+len(x)]. So, here's a short info post on how Python supports negative indices for sequences. Thanks for this. Cou

Re: How Python works: What do you know about support for negative indices?

2010-09-09 Thread Ben Finney
Raymond Hettinger writes: > It doesn't seem to be common knowledge when and how a[x] gets > translated to a[x+len(x)]. So, here's a short info post on how Python > supports negative indices for sequences. Thanks for this. Could you post your messages using a channel that doesn't arbitrarily spl

How Python works: What do you know about support for negative indices?

2010-09-09 Thread Raymond Hettinger
Hello Folks. It doesn't seem to be common knowledge when and how a[x] gets translated to a[x+len(x)]. So, here's a short info post on how Python supports negative indices for sequences. I've put the answer below, but if you want to quickly test your own knowledge, ask yourself which of these sup

Re: how python works

2010-08-01 Thread Terry Reedy
On 7/30/2010 2:16 PM, Mahmood Naderan wrote: So is it a compiler or interpreter? Python is a language. It does not 'work' in the sense of your subject line. CPython is a Python compiler/interpreter, as described. When loaded, it may be named python.exe, depending on system and installation.

Re: how python works

2010-07-30 Thread Mahmood Naderan
quot;interprets" the byte code. >So, it's an interpreter that compiles the code first. Thanks. I got it.   // Naderan *Mahmood; From: Stephen Hansen To: python-list@python.org Sent: Fri, July 30, 2010 11:13:27 PM Subject: Re: how python works On

Re: how python works

2010-07-30 Thread Stephen Hansen
On 7/30/10 11:16 AM, Mahmood Naderan wrote: > So is it a compiler or interpreter? Neither/both, depending on your definition of either word. It does not compile to machine code: it compiles to byte code (which it then usually, but not always, stores in a pyc file alongside the py file). It does no

Re: how python works

2010-07-30 Thread Burton Samograd
Mahmood Naderan writes: > So is it a compiler or interpreter? There's a compiler that compiles python to bytecode which is then interpreted. This saves the interpreter from having to re-parse the code at run time. So, it's an interpreter that compiles the code first. -- Burton Samograd --

Re: how python works

2010-07-30 Thread Mahmood Naderan
So is it a compiler or interpreter?   // Naderan *Mahmood; From: Burton Samograd To: python-list@python.org Sent: Fri, July 30, 2010 10:36:56 PM Subject: Re: how python works Mahmood Naderan writes: > I want to know how python executes a .py file. Someti

Re: how python works

2010-07-30 Thread Burton Samograd
Mahmood Naderan writes: > I want to know how python executes a .py file. Sometimes when I run a > file, I get an error that there is a syntax error. This shows that the > parser read and parse the whole file. Sometimes in the middle of the > run I get an error that another line has problem. So ho

how python works

2010-07-30 Thread Mahmood Naderan
I want to know how python executes a .py file. Sometimes when I run a file, I get an error that there is a syntax error. This shows that the parser read and parse the whole file. Sometimes in the middle of the run I get an error that another line has problem. So how does it work? if it doesn't c