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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T00:18:09+00:00 2026-06-19T00:18:09+00:00

I want to call a function that takes a class as an argument, without

  • 0

I want to call a function that takes a class as an argument, without passing it a class.

The function only uses an integer value from the class, and the place I call it from has information that can calculate the value independently.

My code looks like:

Function I want to call:

    def buckets_from_pairs(fs_pairs,par):
        fsea=fermi_sea(par.N)

        # rest of function has no reference to par

Function I call from:

    def deltas(roots):
        if "buckets" in roots:
            # do function on    roots["buckets"]

        if "partition" in roots:
            #somehow define     value  such that  value.N=len(roots["roots"])

            buckets=buckets_from_pairs(roots["partition"], value)

            #do function on    buckets

I could change deltas to take par as an argument and I could change buckets_from_pairs to work without par but both would require a lot of reworking, and I would have to organise it with my supervisor who wrote both functions (he doesn’t have this problem).

So I was hoping there was a simpler way of creating an object that can use the “dot” to reference something than creating a new class in the calling function.

  • 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-19T00:18:11+00:00Added an answer on June 19, 2026 at 12:18 am
    from collections import namedtuple
    value = namedtuple('Value', 'N')(len(roots["roots"]))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to call a function which is in another php class that I
I want to call a controller function from a view. Is that possible in
I have an ojbect with a function that takes an out argument. I want
I have class with a member function that takes a default argument. struct Class
I want to make a class with a member function that takes a reference
I want to call a function that may throw an exception. If it does
I have function getCartItems in cart.js and I want to call that function in
I'm trying to call a function that contains jQuery code. I want this function
Say I have a function foo that I want to call n times. In
I have a function fun that returns a double. I want to call the

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.