Python's built-in iter function is mostly used to extract an iterator from an iterable (if you're confused by this, see Raymond's excellent answer on StackOverflow).
iter has a second form where it takes a function with not arguments and a sentinel value. This doesn't see that useful but check out the readline example in the documentation. iter will call the function repeatably until it the function return the sentinel value and then will stop.
What happens when the function producing the values require some arguments? I this case we can use functools.partial to create a zero arguments function.
Here's an example of a simple HTTP client using raw sockets, we can directly use join on the iterator.
If it won't be simple, it simply won't be. [Hire me, source code] by Miki Tebeka, CEO, 353Solutions
Subscribe to:
Post Comments (Atom)
2 comments:
Simple and Clear. Keep sharing more and more SEO Online Training
Java Online Training
python Online Training
Salesforce Online Training
Tableau Online Training
AWS Online training
Dot Net OnlineTraining
DevOps Online Training
Selenium Online Training
Nice post..
Windows admin training
Wordpress training
Qliksense training
Post a Comment