Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #89967
| From | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Step further with filebasedMessages |
| Organization | Decebal Computing |
| References | <87oalzh0d5.fsf@Equus.decebal.nl> <55489e80$0$12913$c3e8da3$5496439d@news.astraweb.com> <87fv7bgt6t.fsf@Equus.decebal.nl> <mailman.125.1430834230.12865.python-list@python.org> |
| Date | 2015-05-05 16:51 +0200 |
| Message-ID | <87bnhzgjqr.fsf@Equus.decebal.nl> (permalink) |
Op Tuesday 5 May 2015 15:57 CEST schreef Ian Kelly: > On May 5, 2015 5:46 AM, "Cecil Westerhof" <Cecil@decebal.nl> wrote: >> >> Op Tuesday 5 May 2015 12:41 CEST schreef Steven D'Aprano: >> >>> # Untested. def get_message_slice(message_filename, start=0, >>> end=None, step=1): real_file = expanduser(message_filename) >>> messages = [] # FIXME: I assume this is expensive. Can we avoid >>> it? nr_of_messages = get_nr_of_messages(real_file) >> >> If I want to give the possibility to use negative values also, I >> need the value. > > You could make this call only if one of the boundaries is actually > negative. Then callers that provide positive values don't need to > pay the cost of that case. You have a point there. I will think about it. > Alternatively, consider that it's common for slices of iterators to > disallow negative indices altogether, and question whether you > really need that. It was an idea I got from this newsgroup. :-D And I liked it, otherwise I would not have implemented it. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Step further with filebasedMessages Cecil Westerhof <Cecil@decebal.nl> - 2015-05-05 10:52 +0200
Re: Step further with filebasedMessages Chris Angelico <rosuav@gmail.com> - 2015-05-05 19:20 +1000
Re: Step further with filebasedMessages Cecil Westerhof <Cecil@decebal.nl> - 2015-05-05 12:14 +0200
Re: Step further with filebasedMessages Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-05-05 20:41 +1000
Re: Step further with filebasedMessages Cecil Westerhof <Cecil@decebal.nl> - 2015-05-05 13:27 +0200
Re: Step further with filebasedMessages Ian Kelly <ian.g.kelly@gmail.com> - 2015-05-05 07:57 -0600
Re: Step further with filebasedMessages Cecil Westerhof <Cecil@decebal.nl> - 2015-05-05 16:51 +0200
Re: Step further with filebasedMessages Peter Otten <__peter__@web.de> - 2015-05-05 13:08 +0200
Re: Step further with filebasedMessages Cecil Westerhof <Cecil@decebal.nl> - 2015-05-05 17:25 +0200
Re: Step further with filebasedMessages Dave Angel <davea@davea.name> - 2015-05-05 13:10 -0400
csiph-web