Main.DictionaryVarArgs History

Hide minor edits - Show changes to markup

March 23, 2010, at 11:13 PM MST by 71.196.160.210 -
Added lines 1-30:

(:source lang=python:)

def dictionary_var_args(arg1, arg2 = 'defaultB', **args) :

    print 'formal arg1:', arg1
    print 'formal arg2:', arg2
    print 'the rest:', str(args)
    print 'the type of args', type(args)
  1. you can call it with a single argument:

dictionary_var_args('one')

  1. or two:

dictionary_var_args('one', 'two')

  1. note that in the above two calls the dictionary of additional
  2. arguments is empty

dictionary_var_args('one', 'two')

dictionary_var_args('one', one = 'uno', two = 'dos')

def var_args(*tuple_args, **dict_args) :

    print 'tuple args:', str(tuple_args)
    print 'dictionary args:', dict_args

var_args('one', 'two', one = 'uno', two = 'dos')

(:sourceend:)