Re: [Tutor] Example for read and readlines()

2018-11-11 Thread Steven D'Aprano
On Sun, Nov 11, 2018 at 12:19:36PM +0530, Asad wrote: > Hi All , > > If I am loading a logfile what should I use from the option 1,2,3 Depends what you want to do. I assume that the log file is formatted into lines of text, so you probably want to iterate over each line. with

Re: [Tutor] Require Python assistance

2018-11-11 Thread Alan Gauld via Tutor
On 10/11/2018 18:10, Avi Gross wrote: > WARNING to any that care: > > As the following letter is a repeat request without any hint they read the > earlier comments here, I did a little searching and see very much the same > request on another forum asking how to do this in MATLAB: The OP has

Re: [Tutor] Example for read and readlines()

2018-11-11 Thread Alan Gauld via Tutor
On 11/11/2018 09:40, Steven D'Aprano wrote: >> f3 = open ( r"/a/b/c/d/test/test_2814__2018_10_05_12_12_45/logA.log", 'r' ) > > Don't use raw strings r"..." for pathnames. Umm, Why not? -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/

Re: [Tutor] Example for read and readlines()

2018-11-11 Thread Alan Gauld via Tutor
On 11/11/2018 06:49, Asad wrote: > Hi All , > > If I am loading a logfile what should I use from the option 1,2,3 > > f3 = open ( r"/a/b/c/d/test/test_2814__2018_10_05_12_12_45/logA.log", 'r' ) > > 1) should only iterate over f3 This is best for processing line by line which is the

[Tutor] Example for read and readlines()

2018-11-11 Thread Asad
Hi All , If I am loading a logfile what should I use from the option 1,2,3 f3 = open ( r"/a/b/c/d/test/test_2814__2018_10_05_12_12_45/logA.log", 'r' ) 1) should only iterate over f3 2) st = f3.read() Should iterate over st 3) st1 = f3.readlines() Should iterate over st1 How are

Re: [Tutor] Example for read and readlines()

2018-11-11 Thread Alan Gauld via Tutor
On 11/11/2018 10:04, Asad wrote: > 1) and I want to extract the start time , error number and end > time from this logfile so in this case what should I use I guess option 1 : > > with open(filename, 'r') as f: > for line in f: > process(line) Yes, that woyuld be the best

[Tutor] Bufferin

2018-11-11 Thread Avi Gross
After my earlier message (snipped out for space savings) focused on choosing among various methods to retain a buffer of recent lines from a file, I realized that for many, the best method is simply to import a solution others have created, often in the form of an object. Many of the methods I

[Tutor] (no subject)

2018-11-11 Thread Stealth Fleet
tokenAmount = input( "How many tokens would you like to buy or cash in?: ") print (tokenAmount) def buy (): if tokenAmount <= 400: buy = tokenAmount * .2099 print( " You would like to spend $"+(buy) + "on" + (tokenAmount) + "tokens.") elif tokenAmount > "400" <=

Re: [Tutor] saveLine decked

2018-11-11 Thread Avi Gross
Peter, Appreciated. I wrote something like this in another message before reading yours. Indeed one of the things I found was the deque class in the collections module. But I was not immediately clear on whether that would be directly applicable. Their maximum sounded like if you exceeded it,

Re: [Tutor] (no subject)

2018-11-11 Thread Steven D'Aprano
On Sun, Nov 11, 2018 at 03:00:00PM -0800, Stealth Fleet wrote: [...] > tokenAmount works but the buy and cashIn are not being ran why? You define the function, but never call it. Functions aren't called automatically. py> def example(): ... print("calling example") ... py> py> # nothing is

[Tutor] saveLine

2018-11-11 Thread Avi Gross
Alan and others have answered the questions posed and what I am asking now is to look at the function he proposed to keep track of the last five lines. There is nothing wrong with it but I wonder what alternatives people would prefer. His code is made for exactly 5 lines to be buffered and is

Re: [Tutor] saveLine

2018-11-11 Thread Peter Otten
Avi Gross wrote: > Alan and others have answered the questions posed and what I am asking now > is to look at the function he proposed to keep track of the last five > lines. > > There is nothing wrong with it but I wonder what alternatives people would > prefer. His code is made for exactly 5