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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:07:21+00:00 2026-06-14T13:07:21+00:00

I call a method of an external library multiple times in my class like

  • 0

I call a method of an external library multiple times in my class like this:

class MyClass:

    const_a = "a"
    const_b = True
    const_c = 1

    def push(self, pushee):
        with ExternalLibrary.open(self.const_a, self.const_b, self.const_c) as el:
            el.push(pushee)

    def pop(self):
        with ExternalLibrary.open(self.const_a, self.const_b, self.const_c) as el:
            return el.pop()

The lines containing the with statement are bugging me, because they require passing the the constants as arguments every time. I would like to store the arguments in a predefined data structure like a tuple and pass that to the external library.

  • 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-14T13:07:23+00:00Added an answer on June 14, 2026 at 1:07 pm

    You can do this:

    args = (const_a, const_b, const_c)
    ExternalLibrary.open(*args)
    

    The * syntax unpacks an iterable (tuple, list, etc.) into individual arguments in a function call. There is also a ** syntax for unpacking a dictionary into keyword arguments:

    kwargs = {'foo': 1, 'bar': 2}
    func(**kwargs) # same as func(foo=1, bar=2)
    

    You can also use both in the same call, like func(*args, **kwargs).

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

Sidebar

Related Questions

I'm calling a method from an external library with a (simplified) signature like this:
How to call Html.Partial() method from controller or some other method in external class
I call the method like this: Headers: User-Agent: Fiddler Content-type: application/json Content-length: 116 Host:
My main process calls an external library method. This method sometimes hangs. I can
I call addNotify() method in class that I posted here. The problem is, that
Does anyone know of an algorithm (or external library) that I could call to
I need to call a method in an external assembly from a scripting functoid
The Problem I'm running multiple invocations of some external method via an ExecutorService .
If I call Timer(.1, some_function, [some_arguments]).start() multiple times, what exactly happens behind the scenes?
I have an external library which has a method which performs a long running

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.