Colab

range(10**12)

range(0, 1000000000000)
x = (2**i for i in range(10**12))

next(x)

32
def infinity():
    x = 0 
    while True:
        return x
        x +=1
        
z = infinity()

z = infinity()

def infinity():
    x = 0 
    while True:
        yield x
        x +=1

z = infinity()
z

<generator object infinity at 0x0147D6B0>
next(z)

6
z2 = infinity()

next(z)

7
next(z2)

0
import random
def make_random_stream(n):
    for i in range(n):
        yield random.randint(0, 100)

list(make_random_stream(10))

[38, 86, 9, 61, 83, 57, 88, 29, 22, 9]
z = make_random_stream(100000000000000)

z

<generator object make_random_stream at 0x01673B70>
def make_reader(f):
    pass

for line in make_reader(open('spam.txt')):
    print(line)

from copy import deepcopy

a = [[1],[2],[3] ]
b = a[:]

a[0][0] = 10

a

[[10], [2], [3]]
b

[[10], [2], [3]]
b = deepcopy(a)

a[0][0] = 100

a

[[100], [2], [3]]
b

[[10], [2], [3]]