Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32356
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'argument': 0.04; 'explicitly': 0.04; 'modified': 0.05; 'method,': 0.07; 'override': 0.07; 'wrapper': 0.07; 'api': 0.09; 'python': 0.09; '"a"': 0.09; 'called.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'special,': 0.09; 'subject:()': 0.09; 'suggest': 0.11; 'index': 0.13; '(but': 0.15; 'dictionaries': 0.16; 'dictionary,': 0.16; 'lambda': 0.16; 'notation,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'slice.': 0.16; 'subject:array': 0.16; 'thinking,': 0.16; 'wrote:': 0.17; 'question.': 0.20; 'trying': 0.21; 'defined': 0.22; "haven't": 0.23; 'idea': 0.24; 'pass': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'andrew': 0.27; 'start,': 0.27; 'header:X-Complaints-To:1': 0.28; 'arguments.': 0.29; 'arrays': 0.29; 'array': 0.29; 'class': 0.29; "i'm": 0.29; 'function': 0.30; 'error': 0.30; 'url:python': 0.32; 'from:addr:yahoo.co.uk': 0.32; 'could': 0.32; 'hopefully': 0.33; 'to:addr:python-list': 0.33; 'tutorial': 0.33; 'list': 0.35; 'moved': 0.35; 'sequence': 0.35; 'something': 0.35; 'there': 0.35; 'received:org': 0.36; 'url:org': 0.36; "wasn't": 0.36; 'method': 0.36; 'skip:p 20': 0.36; 'itself': 0.37; 'ok,': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'mark': 0.38; 'object': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'apply': 0.39; 'step': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'range': 0.60; 'back': 0.62; 'mentioned': 0.63; 'information': 0.63; 'love': 0.63; 'more': 0.63; 'within': 0.64; 'to,': 0.65; '*really*': 0.84; 'stop,': 0.84; 'received:89': 0.86 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
| Subject | Re: Negative array indicies and slice() |
| Date | Mon, 29 Oct 2012 10:10:45 +0000 |
| References | <508DEA9D.8040702@r3dsolutions.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | host-89-240-163-148.as13285.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.0; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 |
| In-Reply-To | <508DEA9D.8040702@r3dsolutions.com> |
| X-Antivirus | avast! (VPS 121028-1, 28/10/2012), Outbound message |
| X-Antivirus-Status | Clean |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3003.1351505292.27098.python-list@python.org> (permalink) |
| Lines | 48 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1351505292 news.xs4all.nl 6873 [2001:888:2000:d::a6]:41773 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:32356 |
Show key headers only | View raw
On 29/10/2012 02:31, Andrew Robinson wrote: > Ok, hopefully this is better. I love my own e-mail editor... > > I can see that the slice() function can pass in arbitrary arguments. > I'm not sure for lists, which is what the range is applied to, why an > argument like "a" would be part of a slice. > I *really* don't see what the advantage of a slice class is over a mere > list in the order of start, stop, step eg: [ 1,4,9 ] > > In a dictionary, where "a" could be a key -- I wasn't aware that there > was a defined order that the idea of slice could apply to. > > When I look at the documentation, > http://www.python.org/doc//current/c-api/slice > > The only thing that slice has which is special, is that the the length > of the sequence can be given -- and the start and stop index are either > trimmed or an error (exception???) is thrown. > > Where is the information on the more general case of slice()? :-\ > > I am thinking, can one use the 'super' type of access, to override -- > within the list object itself -- the __getitem__ method, and after > pre-processing -- call the shadowed method with the modified > parameters? That would allow me to use the normal a[-4:6] notation, > without having to write a wrapper class that must be explicitly called. > > I'm thinking something like, > > PyListObject.__getitem__= lambda self, slice: .... > > --Andrew. > I suggest that you go back and read the tutorial about slicing. I say this because we've started with negative array indicies and slice() (but Python arrays haven't been mentioned :), then moved onto (x)range and now lists, dictionaries and the C API for slices. An alternative is to tell us precisely what you're trying to achieve. The odds are that there's a simple answer waiting in the wings for a simple question. -- Cheers. Mark Lawrence.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Negative array indicies and slice() Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-10-29 10:10 +0000
csiph-web