Strange varargs issue

Mike ckimyt at gmail.com
Fri Jan 4 08:45:22 EST 2008


I'm not sure if this is a bug or if I'm just not understanding
something correctly.  I'm running the following (broken.py) on
ActivePython 2.5.1.1, based on Python 2.5.1 (r251:54863 5/1/2007) as
"python broken.py foo" (on Windows, of course):


#!/bin/env python

import sys

class foobar(object):
    def func(arg):
        print 'foobar.func: %r' % arg

__f = foobar()

def caller(a):
    print 'caller: %r' % a
    __f.func(a)

def main():
    rest = sys.argv[1:]
    print 'main: %r' % rest
    caller(*rest)

if __name__ == '__main__':
    main()


...and the result of running this ("python broken.py foo") is:


main: ['foo']
caller: 'foo'
Traceback (most recent call last):
  File "broken.py", line 21, in <module>
    main()
  File "broken.py", line 18, in main
    caller(*rest)
  File "broken.py", line 13, in caller
    __f.func(a)
TypeError: func() takes exactly 1 argument (2 given)


How can this possibly be?  The "caller" print statement obviously
shows "a" is singular.

Thanks in advance for any and all insight...

Mike



More information about the Python-list mailing list