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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:23:04+00:00 2026-05-13T07:23:04+00:00

My python application consists of main program and several modules. Each module contains import

  • 0

My python application consists of main program and several modules. Each module contains

import logging
log = logging.getLogger('myapp.mymodule')

on global level. Handlers and other stuff initialized in main program, and typically all messages forwarded to syslog.

Now I want to launch multiple instances of application (configuration file with instance name can be specified as command line parameter). The question is: how to pass instance name to each imported module? I want logger name to look like ‘myappinstance.mymodule’ or ‘myapp.instance.module’. And I do not want to mess with configuration file parsing in each module, because this will require hardcoded config path.

  • 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-13T07:23:04+00:00Added an answer on May 13, 2026 at 7:23 am

    Well, describing the problem really helps in solving it 🙂 Just had an idea of using environment variables to pass parameters across all modules:

    main.py:

    import os
    os.environ['instance'] = 'blah'
    import a
    

    a.py:

    import os
    import b
    print 'a:', os.environ['instance']
    

    b.py:

    import os
    print 'b:', os.environ['instance']
    

    $ python main.py

    b: blah
    a: blah
    

    Any other ideas or critics for this one?

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

Sidebar

Ask A Question

Stats

  • Questions 291k
  • Answers 291k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you mean, how do you go back and free… May 13, 2026 at 5:56 pm
  • Editorial Team
    Editorial Team added an answer I have gotten it to work, although I'm not sure… May 13, 2026 at 5:56 pm
  • Editorial Team
    Editorial Team added an answer NSBitmapImageRep should get you what you need. Load the data… May 13, 2026 at 5:56 pm

Related Questions

I am writing a simple Python web application that consists of several pages of
How do I set Perl's %ENV to introduce a Perl script into the context
My Python / SQLAlchemy application manages a set of nodes, all derived from a
I'm sorry I could not think of a better title. The problem is the
My Python application currently uses the python-memcached API to set and get objects in

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.