Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8528777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:52:42+00:00 2026-06-11T08:52:42+00:00

def withPositionalArgs(*args): print args, type(args) def withTupleAsArgument(tupleArg): print tupleArg, type(tupleArg) a=1 b=2 c=[10,20] print

  • 0
def withPositionalArgs(*args):
    print args, type(args)

def withTupleAsArgument(tupleArg):
    print tupleArg, type(tupleArg)

a=1
b=2
c=[10,20]

print withPositionalArgs(a,b,c)
print withTupleAsArgument(tuple([a,b,c]))

When I run this code:

(1, 2, [10, 20]) <type 'tuple'>
None
(1, 2, [10, 20]) <type 'tuple'>
None

Doubts:

As positional arguments are passed as a tuple, is there techcnially any difference between these 2 function calls? If I can already make a tuple at the time I’m calling, is there a need to use Positional arguments ? Things can work without them too, ain’t it ? Or is there something that I have not understood or ignored?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:52:43+00:00Added an answer on June 11, 2026 at 8:52 am

    You need to ask yourself how your function will be used. Is it more natural to think of the arguments as an unrelated set of values, in which case positional arguments make more sense. Or do the values form a related group, in which case a tuple makes more sense.

    You also need to consider how your function may be used. Suppose you have a function
    that returns a tuple of values:

    def foo():
        return 1,2,3
    

    and you want to write a function bar whose arguments are those values returned by foo. Your two choices are

    # Take a sequence of values and store them in a tuple called args
    def bar1(*args):
        print args[0]
    
    # Take a tuple of values and store it in t
    def bar2(t):
        print t[0]
    

    Here are some ways you might call each of the two functions, using the return value of foo directly as your argument(s):

    >>> bar1(foo())  # Receives a single tuple-valued argument
    (1, 2, 3)
    >>> bar1(*foo()) # Receives 3 integer arguments
    1
    >>> bar2(foo())  # Receives a single tuple-valued argument
    1
    >>> bar2(*foo()) # Receives 3 arguments, but only expected 1!
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: bar2() takes exactly 1 argument (3 given)
    

    So the choice between bar1 and bar2 really depends on how you expect it to be used.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

def myFunc( str ): print str=, str if str == None: print str is
def minmax (actual, min, max): print 'actual', actual, type(actual) print 'min', min, type(min) print
def download_if_dne(href, filename): if os.path.isfile(filename): # print 'already downloaded:', href return False else: if
def myFunc( a, b ): def innerFunc( c ): print c innerFunc( 2 )
def partial(template, *args) options = args.extract_options! options.merge!(:layout => false) if collection = options.delete(:collection) then
def display_home(request): from datetime import * now=datetime.today() print 'Month is %s'%now.month events=Event.objects.filter(e_date__year=datetime.today().year).filter(e_date__month=datetime.today().month,e_status=1).values('e_name','e_date') return render_to_response("SecureVirtualElection/home.html",{'events':
def merge(l1,l2): i=0; while((l1[i]!=none)||(l2[i]!=none)): SyntaxError: invalid syntax being a newbie i can't figure out
def ask(): global name, loca print What's your name? name = raw_input('> ') print
def applejuice(q): print THE FUNCTION NAME! It should result in applejuice as a string.
def pad_image(f, width=500, height=None): if height==None: height = width image = Image.new(RGB, (800, 600),

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.