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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:09:06+00:00 2026-05-19T22:09:06+00:00

First let me say that I thought that the way data storage worked in

  • 0

First let me say that I thought that the way data storage worked in python is that everything is an object so there is no need for such things as pointers. If you pass an piece of data into a function then that function has the real piece of data. When you exit out of that function it the data passed in could have been modified.

Now I was working with lists and I thought that if I put the same piece of data on two lists then modifying it in one place would modify it in the other.

How can I have one piece of data that is on two, or more, different lists? I would want to change this data in one place and then have the other change.

For example take the following:

p = 9

d = []
f = []
d.append(p)
f.append(p)


print 'd',d
print 'f',f

p = 3

print 'd',d
print 'f',f

When this is run the output is:

d [9]
f [9]
d [9]
f [9]

I would like the second set of data to be 3 but it doesn’t seem to work. So where in my thought process did I go wrong? Is there an implicit copy operation when putting data onto a list?

  • 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-19T22:09:07+00:00Added an answer on May 19, 2026 at 10:09 pm

    First of all, integers (really, number objects) are immutable. There is no “modifying” this “data”.
    Second of all, there is also in Python the notion of name binding. When you do:

    p = 9
    

    Two things happen: first, a number object (9) is created; second, it is then bound to the name p.

    When you later do:

    p = 3
    

    It does not, as you think, “modify” the immutable number object created earlier. What this simply does is, again, two things: first, a new number object (3) is created; second, it is then bound to the name p.

    Pictorally:

    (1a)       9
    (1b) p --> 9
    
    (2a) p --> 9
               3
    (2b)       9
         p --> 3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.