This file contains 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
# If line 4 throw error, line 5 will not execute | |
# and only it will throw | |
try: | |
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: | |
print(e) | |
except NameError as e: | |
print(e) |
This file contains 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
# 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: | |
yield(i) | |
# Create Generator by using Comprehension : |
This file contains 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
//@version=4 | |
study("Relative Strength", shorttitle="RS",resolution = "") | |
comparativeTickerId = input("CNX500", type=input.symbol, title="Comparative Symbol") | |
comparativeSectorId = input("CNXIT", type=input.symbol, title="Sector Symbol") | |
lenght = input(50, type=input.integer, minval=1, title="Period") | |
showMA_1 = input(defval=true, type=input.bool, title="Nifty_RS_MA") | |
showMA_2 = input(defval=true, type=input.bool, title="Sector_RS_MA") | |
showres = input(defval=false, type=input.bool, title="Show RS") | |
showsecres = input(defval=false, type=input.bool, title="Show Sector RS") | |
lenghtMA_1 = input(5, type=input.integer, minval=1, title="Nifty_RS_MA") |