Posts

Showing posts from June, 2022

Command line utility

#there are two types of command line arguments are there #1. positional arguments #- we can give value arguments directly in WPS (windows powershell) #- cant skip any value argument #- expected command in WPS for command line argument program execution ( 4 6 add [note:cant change position]) #2. optional arguments #- we have to give value arguments in WPS with (--argument_name argument_value) #- we can skip any value argument #- expected command in WPS for program execution (--number1 4 --number2 6 --operation add [note:can change position]) import argparse #python built in library import sys if __name__== '__main__' : parser=argparse.ArgumentParser() #parser object # 1. positional arguments # using add_argument function or attribute adding arguments '''parser.add_argument("num1", help="first number") parser.add_argument("num2", help="second number") parser.add_argument(...

'is' vs '==' in python

# '==' : value equality-two objects have the same value # is : reference equality- two references refer to the same object a=[ 1 , 2 , 3 ] b=a #two references refer to the same object(b is not the copy of a) print (b==a) print (b is a) c=a[:] #two references refer to the two different object(now c is the copy of a) print (c==a) print (c is a)