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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:19:38+00:00 2026-05-25T13:19:38+00:00

I read that importing a module’s mutable objects and changing them in-place,affects the original

  • 0

I read that importing a module’s mutable objects and changing them in-place,affects the original imported module’s objects as well.
For instance:

from mymod import x
x[0]=1001

So when I do this:

import mymod
print(mymod.x)

Prints [1001,43,bla].
My question is,does an in-place change this affect a module’s compiled byte code,a module’s source(unlikely isn’t it?) or the namespace that I’ve imported?So if I change something like that,import at a later time the same module somewhere else and try to access the mutable object,what would I get?Cheers.

  • 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-25T13:19:39+00:00Added an answer on May 25, 2026 at 1:19 pm

    No, it doesn’t. When you import that module at a later time (or if another script imports the module at the same time your program is still running) you get your own, “clean” copy of that module.

    So if the test.py contains the single line x = [1,2,3], you get:

    >>> from test import x
    >>> x[0] = 1001
    >>> x
    [1001, 2, 3]
    >>> import test
    >>> test.x
    [1001, 2, 3]
    >>> imp.reload(test)
    <module 'test' from 'test.py'>
    >>> test.x   # test is rebound to a new object 
    [1, 2, 3]
    >>> x        # the old local variable isn't affected, of course
    [1001, 2, 3]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the Python interactive interpreter: I am importing a module that contains a class.
Well, I'm Trying to Make a Data Importing Module. From the module, the user
I have read on MSDN( see Important note ) that RSACryptoServiceProvider must be disposed.
I've read all the advice on const-correctness in C++ and that it is important
I read that you could call JavaScript code from a Java Applet by calling
I read that Domain Driven Design is about concentrating on the problem domain instead
I read that SQL exceptions are treated as normal exceptions in managed SPs; I
I read that you should define your JavaScript functions in the <head> tag, but
I read that defined styles are located at C:\Program Files\Microsoft Office\Office12\Bibliography\Style I use ISO
I read that some webmail services prefetch url links in emails. The GET request

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.