Skip to content

Instantly share code, notes, and snippets.

Shivam Tiwari ShivamPsit

Block or report user

Report or block ShivamPsit

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
ShivamPsit /
Last active Sep 6, 2019
Generator in Python
# Generators don't hold entire result in the memory instead
# it yields one result at a time and
# takes less memory and time to execute
def cube_num(num):
for i in num:
# Create Generator by using Comprehension :
ShivamPsit /
Last active Sep 6, 2019
# If line 4 throw error, line 5 will not execute
# and only it will throw
f = open('file.txt') # If file didn't found this line will throw 'FileNotFoundError'
m = any_var # This line will throw 'NameError'
except FileNotFoundError as e:
except NameError as e:
You can’t perform that action at this time.