How Dyslexia Affects Reading and Writing

If you wonder if your child has dyslexia, here is an overview of this condition. Dyslexia is a condition where someone may struggle with reading fluently. One sign of dyslexia is the inability to…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




passing parameter to a function

what is a better approach to pass parameter to a function ?

before digging deep, we should understand the difference between a parameter and argument.

most of the time we get confused between a parameter and a argument.

when a call is made to a function, whatever is being passed is called as parameter(s)

udf1(p)

here “p” is a parameter

whereas “a” is an argument in the below case

def udf1(a):

print “hello — ” + a

coming back to the original question, below are few approaches with pros and cons

approach 1:

number of parameters passed are few (< 4)

udf1(p1, p2, p3)

pros :

cons:

approach 2:

number of parameters are more (>= 4)

udf1(kwargs)

where kwargs = {‘p1’: <val>, ‘p2’: <val>, ‘p3’: <val>, ‘p4’: <val>…}

pros :

cons :

approach 3

don’t pass parameters, parameters are derived from global/env variables

udf1()

pros :

cons :

Add a comment

Related posts:

She was named Havana.

I read and meditate on her every morning. Biographical accounts, nautical recollecitons, economic analysis. I try to logically pry my mind off of Havana. A whispering dream. The maverick sailors, the…