Re: Question about yield

2015-11-16 Thread Steven D'Aprano
On Sun, 15 Nov 2015 01:37 pm, fl wrote: > Hi, > I have read a couple of tutorial on yield. The following code snippet > still gives me a shock. I am told yield is a little like return. I only > see one yield in the tutorial examples. Here it has two yields. And there > are three variables

Re: Question about yield

2015-11-14 Thread Chris Angelico
On Sun, Nov 15, 2015 at 1:37 PM, fl wrote: > Or are there some high relevant tutorial on this? > Start here: https://docs.python.org/3/tutorial/index.html ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: A question about yield

2010-11-08 Thread Simon Brunning
On 7 November 2010 18:14, Chris Rebert c...@rebertia.com wrote: On Sun, Nov 7, 2010 at 9:56 AM, chad cdal...@gmail.com wrote: But what happens if the input file is say 250MB? Will all 250MB be loaded into memory at once? No. As I said, the file will be read from 1 line at a time, on an

A question about yield

2010-11-07 Thread chad
I have an input file named 'freq' which contains the following data 123 0 133 3 146 1 200 0 233 10 400 2 Now I've attempted to write a script that would take a number from the standard input and then have the program return the number in the input file that is closest to that input file.

Re: A question about yield

2010-11-07 Thread chad
On Nov 7, 9:34 am, chad cdal...@gmail.com wrote: I have an input file named 'freq' which contains the following data 123 0 133 3 146 1 200 0 233 10 400 2 Now I've attempted to write a script that would take a number from the standard input and then have the program return the number

Re: A question about yield

2010-11-07 Thread Chris Rebert
On Sun, Nov 7, 2010 at 9:34 AM, chad cdal...@gmail.com wrote: snip #!/usr/local/bin/python import sys def construct_set(data):    for line in data:        lines = line.splitlines()        for curline in lines:            if curline.strip():                key = curline.split(' ')        

Re: A question about yield

2010-11-07 Thread chad
On Nov 7, 9:47 am, Chris Rebert c...@rebertia.com wrote: On Sun, Nov 7, 2010 at 9:34 AM, chad cdal...@gmail.com wrote: snip #!/usr/local/bin/python import sys def construct_set(data):    for line in data:        lines = line.splitlines()        for curline in lines:          

Re: A question about yield

2010-11-07 Thread Chris Rebert
On Sun, Nov 7, 2010 at 9:56 AM, chad cdal...@gmail.com wrote: On Nov 7, 9:47 am, Chris Rebert c...@rebertia.com wrote: On Sun, Nov 7, 2010 at 9:34 AM, chad cdal...@gmail.com wrote: snip #!/usr/local/bin/python import sys def construct_set(data):    for line in data:        lines =