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 522265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:20:10+00:00 2026-05-13T08:20:10+00:00

def a(): print ‘aa’ def b(): print ‘bb’ def c(*x): print x def d(x,y):

  • 0
def a():
    print 'aa'
def b():
    print 'bb'

def c(*x):
    print x

def d(x,y):
    c(*(x+y))

d(a,b)

Traceback (most recent call last):
  File "D:\zjm_code\mysite\zjmbooks\a.py", line 15, in <module>
    d(a,b)
  File "D:\zjm_code\mysite\zjmbooks\a.py", line 13, in d
    c(*(x+y))
TypeError: unsupported operand type(s) for +: 'function' and 'function'

the code in django.utils.functional.py:

def curry(_curried_func, *args, **kwargs):
    def _curried(*moreargs, **morekwargs):
        return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs))
    return _curried

WRAPPER_ASSIGNMENTS = ('__module__', '__name__', '__doc__')
WRAPPER_UPDATES = ('__dict__',)
def update_wrapper(wrapper,
                   wrapped,
                   assigned = WRAPPER_ASSIGNMENTS,
                   updated = WRAPPER_UPDATES):
    for attr in assigned:
        try:
            setattr(wrapper, attr, getattr(wrapped, attr))
        except TypeError: # Python 2.3 doesn't allow assigning to __name__.
            pass
    for attr in updated:
        getattr(wrapper, attr).update(getattr(wrapped, attr))
    return wrapper

def wraps(wrapped,
          assigned = WRAPPER_ASSIGNMENTS,
          updated = WRAPPER_UPDATES):
    return curry(update_wrapper, wrapped=wrapped,
                 assigned=assigned, updated=updated)

### End from Python 2.5 functools.py ##########################################

def memoize(func, cache, num_args):
    def wrapper(*args):
        mem_args = args[:num_args]
        if mem_args in cache:
            return cache[mem_args]
        result = func(*args)
        cache[mem_args] = result
        return result
    return wraps(func)(wrapper)

my Analysis:

def curry(update_wrapper, *args, **kwargs):
    def _curried(*wrapper, **morekwargs):
        return update_wrapper(wrapper,{wrapped:func})#this is the result
    return _curried
def update_wrapper(wrapper,wrapped)

def wraps(func):
    return curry(update_wrapper, wrapped=func)

wraps(func)(wrapper)
  • 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-05-13T08:20:10+00:00Added an answer on May 13, 2026 at 8:20 am

    Your code (in x+y, where x is a and y is b) is trying to sum two functions (instead of calling them and summing their results, for example): function objects cannot be summed, so your code raises an exeption.

    The code you quote, in args+moreargs, is summing two tuples: tuples can of course perfectly well be summed, it means concatenating them. Absolutely no relation whatsoever to the absurd “sum of two functions” your code is attempting.

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

Sidebar

Related Questions

def test(): print 'test' def test2(): print 'test2' test = {'test':'blabla','test2':'blabla2'} for key, val
For example: def foo(): print 'foo' return 1 if any([f() for f in [foo]*3]):
In file1.py: def test1(): print hi In file2.py: from file1 import test1 def test2():
I have a foo.py def foo(): print test In IPython I use: In [6]:
I have the following code: def countdown(): def countdown1(): print 'countdown1' def countdown2(): def
I have 2 files that print a singleton instance, but I get two different
str2 = Global class InClass: str2 = Class def Set(self, msg): self.str2 = msg
[Python 3.1] Edit: mistake in the original code. I need to print a table.
I am trying to make a textual game in python. All goes well however,
I was looking to do something like what I believe change control systems do,

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.