def c(*x,**y):
print x,y
def a(*x,**y):
print x
def b(*x1,**y1):
c(*(x+x1),**dict(y,**y1))
b()
a(1,2,3,a=1,b=2)(4,5,6,c='222',d='aaa')#error
thanks
def c(*x,**y):
print x,y
def a(*x,**y):
print x
def b(*x1,**y1):
c(*(x+x1),**dict(y,**y1))
b()
a(1,2,3,a=1,b=2)(4,5,6,c='222',d='aaa')#error
thanks
Replace b() with return b
Running this in Python 3.1:
def c(*x,**y):
print(x,y)
def a(*x,**y):
print(x)
def b(*x1,**y1):
c(*(x+x1),**dict(y,**y1))
return b
a(1,2,3,a=1,b=2)(4,5,6,c='222',d='aaa')
produces:
>>> ================================ RESTART ================================
>>>
(1, 2, 3)
(1, 2, 3, 4, 5, 6) {'a': 1, 'c': '222', 'b': 2, 'd': 'aaa'}
>>>
function a() is not returning a function; actually, it returns None. Therefore, the second set of parenthesis is a call on None object - and that's an error.
Did you intend to return a function, like doing something like return b?
a(1,2,3,a=1,b=2)(4,5,6,c='222',d='aaa')#error
I assume you got "object is not callable" exception..
May be you need to return a function object 'b' (not result of the 'b') ?
So instead of
b()
try
return b # without braces and with 'return'
The error I get is:
Traceback (most recent call last):
File "./tmp.py", line 11, in a(1,2,3,a=1,b=2)(4,5,6,c='222',d='aaa') TypeError: 'NoneType' object is not callable
I can fix this by changing your code to:
#!/usr/bin/python
def c(*x,**y):
print x,y
def a(*x,**y):
print x
def b(*x1,**y1):
c(*(x+x1),**dict(y,**y1))
return b
a(1,2,3,a=1,b=2)(4,5,6,c='222',d='aaa')
This produces the output:
(1, 2, 3)
(1, 2, 3, 4, 5, 6) {'a': 1, 'c': '222', 'b': 2, 'd': 'aaa'}
You haven't stated what you're trying to achieve though, so I don't know whether or not this is what you want.