Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!feeds.phibee-telecom.net!news.panservice.it!feed.xsnews.nl!border02.ams.xsnews.nl!feeder04.ams.xsnews.nl!feeder02.ams.xsnews.nl!abp002.ams.xsnews.nl!frontend-F09-17.ams.news.kpn.nl From: Cecil Westerhof Newsgroups: comp.lang.python Subject: Re: seek operation in python Organization: Decebal Computing References: <8b2bd328-08a6-4211-85c4-8d117d1aae1e@googlegroups.com> <87vbge9lm6.fsf@Equus.decebal.nl> <87y4lavy4q.fsf@Equus.decebal.nl> X-Face: "(y8cC@tg_12{">GF'UXTW]FHI2wMiZNrnf'1EFQ&O#$m:f#O7+7}kR,v+Pti8=Vi/Z"g^?b"E X-Homepage: http://www.decebal.nl/ Date: Thu, 30 Apr 2015 22:50:44 +0200 Message-ID: <87r3r1s5ln.fsf@Equus.decebal.nl> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:yMndvoBse7kuxw/ZtbTRR5i3l70= MIME-Version: 1.0 Content-Type: text/plain Lines: 25 NNTP-Posting-Host: 81.207.62.244 X-Trace: 1430428491 news.kpn.nl 18716 81.207.62.244@kpn/81.207.62.244:40912 Xref: csiph.com comp.lang.python:89675 Op Thursday 30 Apr 2015 21:38 CEST schreef Larry Hudson: > On 04/30/2015 01:06 AM, Cecil Westerhof wrote: > [snip] > >> I wrote a module where I have: >> def get_indexed_message(message_filename, index): >> """ >> Get index message from a file, where 0 gets the first message >> """ >> >> return open(expanduser(message_filename), >> 'r').readlines()[index].rstrip() >> > Very minor nit unrelated to the file closing question: > This would be a good place to give index a default value... > > def get_indexed_message(message_filename, index=0): Why would you want this? I think the index should always be defined. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof