Re: Step further with filebasedMessages

2015-05-05 Thread Dave Angel
On 05/05/2015 11:25 AM, Cecil Westerhof wrote: I have a file with quotes and a file with tips. I want to place random messages from those two (without them being repeated to soon) on my Twitter page. This I do with ‘get_random_message’. I also want to put the first message of another file and r

Re: Step further with filebasedMessages

2015-05-05 Thread Cecil Westerhof
Op Tuesday 5 May 2015 13:08 CEST schreef Peter Otten: > Cecil Westerhof wrote: > >> I now defined get_message_slice: >> ### Add step >> def get_message_slice(message_filename, start, end): > > Intervals are usually half-open in Python. I recommend that you > follow that convention. I will change

Re: Step further with filebasedMessages

2015-05-05 Thread Cecil Westerhof
Op Tuesday 5 May 2015 15:57 CEST schreef Ian Kelly: > On May 5, 2015 5:46 AM, "Cecil Westerhof" 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

Re: Step further with filebasedMessages

2015-05-05 Thread Ian Kelly
On May 5, 2015 5:46 AM, "Cecil Westerhof" 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 expe

Re: Step further with filebasedMessages

2015-05-05 Thread Cecil Westerhof
Op Tuesday 5 May 2015 12:41 CEST schreef Steven D'Aprano: > On Tuesday 05 May 2015 18:52, Cecil Westerhof wrote: > >> I now defined get_message_slice: >> ### Add step >> def get_message_slice(message_filename, start, end): >> """ >> Get a slice of messages, where 0 is the first message >> Works wi

Re: Step further with filebasedMessages

2015-05-05 Thread Peter Otten
Cecil Westerhof wrote: > I now defined get_message_slice: > ### Add step > def get_message_slice(message_filename, start, end): Intervals are usually half-open in Python. I recommend that you follow that convention. > """ > Get a slice of messages, where 0 is the first m

Re: Step further with filebasedMessages

2015-05-05 Thread Cecil Westerhof
Op Tuesday 5 May 2015 11:20 CEST schreef Chris Angelico: > On Tue, May 5, 2015 at 6:52 PM, Cecil Westerhof wrote: >> I now defined get_message_slice: > > You're doing a lot of work involving flat-file storage of sequential > data. There are two possibilities: > > 1) Your files are small, so you s

Re: Step further with filebasedMessages

2015-05-05 Thread Steven D'Aprano
On Tuesday 05 May 2015 18:52, Cecil Westerhof wrote: > I now defined get_message_slice: > ### Add step > def get_message_slice(message_filename, start, end): > """ > Get a slice of messages, where 0 is the first message > Works with negative indexes > The va

Re: Step further with filebasedMessages

2015-05-05 Thread Chris Angelico
On Tue, May 5, 2015 at 6:52 PM, Cecil Westerhof wrote: > I now defined get_message_slice: You're doing a lot of work involving flat-file storage of sequential data. There are two possibilities: 1) Your files are small, so you shouldn't concern yourself with details at all - just do whatever look