Created
September 20, 2023 16:55
-
-
Save MacTechIN/bf1297483c05640a5feef1e90d49b14c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def get_natural_number(): | |
n = 0 | |
while True: | |
n += 1 | |
yield n | |
g = get_natural_number() | |
for x in range(0,100): | |
print(next(g)) | |
print("=== generator test using yield (funny)======") | |
def generator(): | |
yield 1 | |
yield 'string' | |
yield True | |
g= generator() | |
for x in range(0,3): | |
print(next(g)) | |
print("++++++++++++++++++++++") | |
a = [n for n in range(1000000)] | |
b = range(1000000) | |
print("is same length ? ", len(a)==len(b)) | |
print("is it same object?",a==b) | |
print("*"*50) | |
# print("a is ", a) | |
print("b is ", b) | |
print("type of a is " , type(a)) | |
print("type of b is " , type(b)) | |
print("Size of a is : ",sys.getsizeof(a)) | |
print("Size of b is : ",sys.getsizeof(b)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
파이썬 공부하면서 알게 된 일반적이지 않는 사용법 모음