844-NOGALIS (844-664-2547)
Nogalis, Inc.
  • Link to Facebook
  • Link to X
  • Link to LinkedIn
  • Link to Mail
  • Company
    • News, Events and Articles
    • About Us
  • Products
    • Infor Lawson Data Archive
    • PeopleSoft Data Archive
    • Oracle Data Archive
  • Services
    • Infor Lawson Support
    • Infor Lawson / CloudSuite Consulting
  • Education & Training
  • Support
  • Contact Us
  • Click to open the search input field Click to open the search input field Search
  • Menu Menu

Passing Parameters to a Thread Target in Python

Articles, Frontpage Article, News

When working with multithreading in Python, a common question is whether you can pass parameters to the function executed by a thread. The short answer is yes — Python’s threading. Thread class provides built-in support for this.

This post walks through the correct and idiomatic ways to pass arguments to a thread target function.


The Basic Thread Pattern

A typical thread is created like this:

import threading

 

t = threading.Thread(target=compare_totals)

t.start()

This works only if compare_totals takes no parameters. If your function requires inputs, you must supply them explicitly.


Passing Positional Arguments with args

Use the args parameter to pass positional arguments to the target function. args must be a tuple.

def compare_totals(source, target):

print(source, target)

 

t = threading.Thread(

target=compare_totals,

args=(“athena”, “oracle”)

)

t.start()

Each element in the tuple maps to a parameter in the function signature.


Passing Keyword Arguments with kwargs

If you prefer named arguments (or want clearer intent), use kwargs:

def compare_totals(source, target):

print(source, target)

 

t = threading.Thread(

target=compare_totals,

kwargs={

“source”: “athena”,

“target”: “oracle”

}

)

t.start()

This approach is especially helpful when a function takes many parameters or optional values.


Passing a Single Object (Such as a Dictionary)

A common pattern is to pass a single dictionary containing multiple configuration values:

def compare_totals(params):

print(params)

 

params = {

“engine”: “mysql”,

“schema”: “public”,

“table”: “employees”

}

 

t = threading.Thread(

target=compare_totals,

args=(params,)

)

t.start()

⚠️ Important:
When passing a single argument via args, you must include a trailing comma: (params,). Without it, Python will not treat the value as a tuple.


Summary

  • Use args for positional arguments
  • Use kwargs for named arguments
  • Always pass args as a tuple, even for a single value
  • Thread targets behave just like normal function calls — the thread simply invokes the function with the supplied parameters

Understanding this pattern makes it much easier to parallelize work cleanly and safely in Python.

 

Retiring Lawson, PeopleSoft, or Oracle? APIX archives the entire application — every table, every year, attachments and security included — into your own AWS account in about 30 days, so you can decommission the legacy system and keep full access to the history.

See how the APIX ERP archive works →

07/28/2026
Share this entry
  • Share on Facebook
  • Share on X
  • Share on WhatsApp
  • Share on LinkedIn
  • Share on Reddit
  • Share by Mail
https://www.nogalis.com/wp-content/uploads/2026/07/Passing-Parameters-to-a-Thread-Target-in-Python.jpg 470 470 Angeli Menta https://www.nogalis.com/wp-content/uploads/2013/04/logo-with-slogan-good.png Angeli Menta2026-07-28 08:58:422026-07-24 13:00:43Passing Parameters to a Thread Target in Python

LEGACY ERP DATA ARCHIVE SOLUTION



Discover how our clients are leveraging AWS services to archive their Legacy ERP data and provide ubiquitous access to users via a light-weight, secure, and read-only web interface. Secure, Fast, Reliable, and Cost Effective. That is the promise of APIX. Follow the link below to find out more and book a discovery call with our data archive specialist.

BOOK DEMO

© Copyright - Nogalis, Inc. 2026
  • Legal
  • Privacy
  • Contact Us
Link to: Hybrid architecture as a permanent enterprise model Link to: Hybrid architecture as a permanent enterprise model Hybrid architecture as a permanent enterprise model Link to: The Hidden Costs of Over-Customizing Your ERP System Link to: The Hidden Costs of Over-Customizing Your ERP System The Hidden Costs of Over-Customizing Your ERP System
Scroll to top Scroll to top Scroll to top