0

Is there any hierarchy to pass arguments in python..?

>>>def anyFun(a,tuple,dictionary)

Should we pass int/str then tuple and then dictionary.

>>>def anyFun1(dictionary,tuple,a)

Should we pass int/str then dictionary and then tuple

>>>def anyFun2(tuple,a,dictionary)

Should we pass tuple then int/str and then dictionary.

or we can pass the arguments in python as in other programming languages. Please help me on this .

2 Answers 2

1

My experience is python is quite limited. But as far as I know, the order you pass the arguments to a function won't really 'cause any major effects.

Sign up to request clarification or add additional context in comments.

2 Comments

There is a difference if we do not pass the argument in proper sequence .
@bittu sorry wrong choice of words. What I meant is that the order of arguments to be passed when we define a function doesn't matter. Whether we define our function to accept a tuple or an int first doesn't matter.
0
have a function with arguments as Tuple and Dictionary:
def fo(*args,**li):
     print args
     print "args is of type:",type(args)#->is a tuple
     print li 
     print "**li is of type:",type(li) #-> ** is dictionary 
fo( a=8,b=9,c='as',1,3,4,)
Output : Will throw an error 

Correct way to pass an argument(in this case Tuple and Dictionary) :
fo(1,3,4, a=8,b=9,c='as')
Output: 
(1, 3, 4)
args is of type: <type 'tuple'>
{'a': 8, 'c': 'as', 'b': 9}
**li is of type: <type 'dict'>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.