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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:46:07+00:00 2026-06-06T14:46:07+00:00

In all of the examples, a is : >>> def a(): … print aaaaaaa

  • 0

In all of the examples, a is :

>>> def a():
...     print "aaaaaaa"

I have been passed a function object from another piece of code, and I need to execute that function.

When I say “function object”, I mean an object like this:

>>> type(a)
<type 'function'>

Have a look at this:

>>> def function(f):
...     print "start"
...     f
...     print "end"

>>> function(a)
start
end

If function() was executing the function it was passed, the output would have an aaaaaaa in the middle of it (returned from a(), which was the function passed to it)

So how can I execute a function when passed the function object?

(Sorry if this isn’t very clear, I’m confusing myself as well…)

  • 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-06T14:46:07+00:00Added an answer on June 6, 2026 at 2:46 pm

    Just call it using the function call operator ():

    f()
    

    This is how you would have called a after defining it. The global name a points to the same function object as the local name f, so you need to do the same thing to call them.

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

Sidebar

Related Questions

All examples are taken from the SICP Book: http://sicpinclojure.com/?q=sicp/1-3-3-procedures-general-methods This was motivated from the
Suppose we have abstract class A (all examples in C#) public abstract class A
All the examples I have seen where the PropertyPlaceHolderConfigurer is used seem to be
All the examples I've seen regarding a RESTful architecture have dealt with a single
I've seen plenty of examples of people extracting all of the classes from a
I'm using exactly the code in the examples from here: http://code.google.com/apis/picasaweb/docs/1.0/developers_guide_python.html#Auth Still no dice.
I have been searching for hours through all the posts regarding LinkedHashMap but I
I was browsing the Django source code and I saw this function: def colorize(text='',
All web.py form examples are in the following format (from webpy.org): myform = form.Form(
I have been trying to figure out how all this validation works, but I

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.