...

Full Bio

Google Go Language Future, Programming Language Programmer Will Get Best Paid Jobs

41 days ago

New Coder Tool Promises to Turbo-Charge Coding In Major Programming Language

42 days ago

Why Many Companies Plan To Double Artificial Intelligence Projects In The Next Year

42 days ago

Why 75% SMBs Are Not Worried About Artifical Intelligence Killing Their Jobs

42 days ago

Interview Study Guide for Data Science To Get Job Quickly

45 days ago

Highest Paying Programming Language, Skills: Here Are The Top Earners

634689 views

Top 10 Best Countries for Software Engineers to Work & High in-Demand Programming Languages

454974 views

Which Programming Languages in Demand & Earn The Highest Salaries?

441045 views

50+ Data Structure, Algorithms & Programming Languages Interview Questions for Programmers

260079 views

100+ Data Structure, Algorithms & Programming Language Interview Questions Answers for Programmers - Part 1

222546 views

### How, why & When - you should use Python Generators

**Generators have been an important part of Python ever since they were introduced with PEP 255.**

for divisor in range(2, int(number ** 0.5) + 1):

if number % divisor == 0:

return False

return True

class Primes:

def __init__(self, max):

self.max = max

self.number = 1

def __iter__(self):

return self

def __next__(self):

self.number += 1

if self.number >= self.max:

raise StopIteration

elif check_prime(self.number):

return self.number

else:

primes = Primes(100000000000)

print(primes)

for x in primes:

print(x)

---------

<__main__.Primes object at 0x1021834a8>

2

3

5

7

11

...

def Primes(max):

number = 1

while number < max:

number += 1

if check_prime(number):

yield number

primes = Primes(100000000000)

print(primes)

for x in primes:

print(x)

---------

<generator object Primes at 0x10214de08>

2

3

5

7

11

.

primes = (i for i in range(2, 100000000000) if check_prime(i))

print(primes)

for x in primes:

print(x)

---------

<generator object <genexpr> at 0x101868e08>

2

3

5

7

11

...