Skip to content

Magenaut

  • Home
  • Topics
    • Notes
    • Tutorial
    • Bug fixing
    • Extension
    • Server
  • Q&A
  • Privacy Policy
  • About

generator

Lazy Method for Reading Big File in Python?

August 22, 2022 by Magenaut

I have a very big file 4GB and when I try to read it my computer hangs.
So I want to read it piece by piece and after processing each piece store the processed piece into another file and read next piece.

Categories Python, Q&A Tags file-io, generator, python Leave a comment

Generator expressions vs. list comprehensions

August 22, 2022 by Magenaut

When should you use generator expressions and when should you use list comprehensions in Python?

Categories Python, Q&A Tags generator, list-comprehension, python Leave a comment

Understanding generators in Python

August 22, 2022 by Magenaut

I am reading the Python cookbook at the moment and am currently looking at generators. I’m finding it hard to get my head round.

Categories Python, Q&A Tags generator, python Leave a comment

What’s the purpose of “send” function on Python generators?

August 20, 2022 by Magenaut

Can someone give me an example of why the “send” function associated with Python generator function exists? I fully understand the yield function. However, the send function is confusing to me. The documentation on this method is convoluted:

Categories Python, Q&A Tags generator, python Leave a comment

What can you use generator functions for?

August 20, 2022 by Magenaut

I’m starting to learn Python and I’ve come across generator functions, those that have a yield statement in them. I want to know what types of problems that these functions are really good at solving.

Categories Python, Q&A Tags generator, python Leave a comment

How to take the first N items from a generator or list?

August 19, 2022 by Magenaut

You can’t slice a generator directly in Python. itertools.islice() will wrap an object in a new slicing generator using the syntax itertools.islice(generator, start, stop, step)

Categories Python, Q&A Tags generator, list, python Leave a comment

Return in generator together with yield in Python 3.3

August 19, 2022 by Magenaut

In Python 2 there was an error when return was together with yield in function definition. But for this code in Python 3.3

Categories Python, Q&A Tags generator, python, python-3.x Leave a comment

How do I know if a generator is empty from the start?

August 19, 2022 by Magenaut

Is there a simple way of testing if the generator has no items, like peek, hasNext, isEmpty, something along those lines?

Categories Python, Q&A Tags generator, python Leave a comment

Reading from a frequently updated file

August 19, 2022 by Magenaut

I’m currently writing a program in python on a Linux system. The objective is to read a log file and execute a bash command upon finding a particular string. The log file is being constantly written to by another program.

Categories Python, Q&A Tags file-io, fopen, generator, python Leave a comment

How to print a generator expression?

August 19, 2022 by Magenaut

In the Python shell, if I enter a list comprehension such as:

Categories Python, Q&A Tags generator, iterator, python Leave a comment
Older posts
Page1 Page2 … Page4 Next →
  1. michealSmith07 on Is there a way to dynamically refresh the less command?August 21, 2022

    That is a very nice post. I like this post.

  2. anonymous on Fix libwacom9 dependency issue when upgrade DebianJune 27, 2022

    saved my day!! Thanks for the help…

  3. sreedhar on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    Thanks its working

  4. saintnick on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    remove libwacom2 worked for me as well

  5. ranafoul on Fix libwacom9 dependency issue when upgrade DebianApril 22, 2022

    apt remove libwacom2 helped on kali 2022.01. gr8

.net ajax asp.net asp.net-core asp.net-mvc asp.net-mvc-3 asp.net-mvc-4 asp.net-web-api bash c# command-line css custom-post-types custom-taxonomy dataframe dictionary django entity-framework functions gridview html iis javascript jquery json linux list matplotlib numpy pandas php plugin-development plugins posts python python-2.7 python-3.x security shell shell-script sql string vb.net webforms wp-query

© 2026 Magenaut • Built with GeneratePress