On Fri, 14 Feb 2014 22:21:11 -0500, Roy Smith used a generator:
print g1.next()
Roy, unless you're stuck with Python 2.5 (or older!), you ought to use
the built-in function next(g1) rather than directly call the next method.
Not only is this the recommended way to do it, but it's also more
Chris Angelico wrote:
On Sat, Feb 15, 2014 at 6:27 PM, Ian Kelly ian.g.ke...@gmail.com wrote:
On Fri, Feb 14, 2014 at 8:31 PM, Nick Timkovich prometheus...@gmail.com
wrote:
OK, now the trick; adding `data = None` inside the generator works, but
in my actual code I wrap my generator inside of
On 15/02/2014 03:31, Nick Timkovich wrote:
OK, now the trick; adding `data = None` inside the generator works, but
in my actual code I wrap my generator inside of `enumerate()`, which
seems to obviate the fix. Can I get it to play nice or am I forced to
count manually. Is that a feature?
On
I have a Python 3.x program that processes several large text files that
contain sizeable arrays of data that can occasionally brush up against the
memory limit of my puny workstation. From some basic memory profiling, it
seems like when using the generator, the memory usage of my script balloons
On Fri, Feb 14, 2014 at 3:27 PM, Nick Timkovich prometheus...@gmail.com wrote:
I have a Python 3.x program that processes several large text files that
contain sizeable arrays of data that can occasionally brush up against the
memory limit of my puny workstation. From some basic memory
Ah, I think I was equating `yield` too closely with `return` in my head.
Whereas `return` results in the destruction of the function's locals,
`yield` I should have known keeps them around, a la C's `static` functions.
Many thanks!
--
https://mail.python.org/mailman/listinfo/python-list
In article mailman.6952.1392433921.18130.python-l...@python.org,
Nick Timkovich prometheus...@gmail.com wrote:
Ah, I think I was equating `yield` too closely with `return` in my head.
Whereas `return` results in the destruction of the function's locals,
`yield` I should have known keeps them
OK, now the trick; adding `data = None` inside the generator works, but in
my actual code I wrap my generator inside of `enumerate()`, which seems to
obviate the fix. Can I get it to play nice or am I forced to count
manually. Is that a feature?
On Fri, Feb 14, 2014 at 9:21 PM, Roy Smith
On Fri, Feb 14, 2014 at 8:31 PM, Nick Timkovich prometheus...@gmail.com wrote:
OK, now the trick; adding `data = None` inside the generator works, but in
my actual code I wrap my generator inside of `enumerate()`, which seems to
obviate the fix. Can I get it to play nice or am I forced to
On Sat, Feb 15, 2014 at 6:27 PM, Ian Kelly ian.g.ke...@gmail.com wrote:
On Fri, Feb 14, 2014 at 8:31 PM, Nick Timkovich prometheus...@gmail.com
wrote:
OK, now the trick; adding `data = None` inside the generator works, but in
my actual code I wrap my generator inside of `enumerate()`, which
10 matches
Mail list logo