Skip to content

Instantly share code, notes, and snippets.

@MacTechIN
Created September 20, 2023 16:55
Show Gist options
  • Save MacTechIN/bf1297483c05640a5feef1e90d49b14c to your computer and use it in GitHub Desktop.
Save MacTechIN/bf1297483c05640a5feef1e90d49b14c to your computer and use it in GitHub Desktop.
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))
@MacTechIN
Copy link
Author

파이썬 공부하면서 알게 된 일반적이지 않는 사용법 모음

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment