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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:02:17+00:00 2026-06-13T00:02:17+00:00

a = [1,2,3,4,5] b = a[1] print id(a[1],b) # out put shows same id.hence

  • 0
a = [1,2,3,4,5]
b = a[1]
print id(a[1],b)   # out put shows same id.hence both represent same object.
del a[1]           # deleting a[1],both a[1],b have same id,hence both are aliases
print a            # output: [1,3,4,5]
print b            # output: 2

Both b,a[1] have same id but deleting one isn’t effecting the other.Python reference states that 'del' on a subscription deletes the actual object,not the name object binding. Output: [1,3,4,5] proves this statement.But how is it possible that ‘b’ remains unaffected when both a[0] and b have same id.

Edit: The part 'del' on a subscription deletes the actual object,not the name object binding is not true.The reverse is true. ‘del’ actually removes the name,object bindings.In case of ‘del’ on subscription (eg. del a[1]) removes object 2 from the list object and also removes the current a[1] binding to 2 and makes a[1] bind to 3 instead. Subsequent indexes follow the pattern.

  • 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-13T00:02:18+00:00Added an answer on June 13, 2026 at 12:02 am

    del doesn’t delete objects, it deletes references.

    There is an object which is the integer value 2. That one single object was referred to by two places; a[1] and b.

    You deleted a[1], so that reference was gone. But that has no effect on the object 2, only on the reference that was in a[1]. So the reference accessible through the name b still reaches the object 2 just fine.

    Even if you del all the references, that has no effect on the object. Python is a garbage collected language, so it is responsible for noticing when an object is no longer referenced anywhere at all, so that it can reclaim the memory occupied by the object. That will happen some time after the object is no longer reachable.1


    1 CPython uses reference counting to implement it’s garbage collection2, which allows us to say that objects will usually be reclaimed as soon as their last reference dies, but that’s an implementation detail not part of the language specification. You don’t have to understand exactly how Python collects its garbage and shouldn’t write programs that depend on it; other Python implementations such as Jython, PyPy, and IronPython do not implement garbage collection this way.

    2 Plus an additional garbage collection mechanism to detect cyclic garbage, which reference counting can’t handle.

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

Sidebar

Related Questions

I want to print columnar output from a ruby program, but in order to
I'm trying to print the output of function only when it is true but
I want to use pprint's output to show a complex data structure, but I
In the following code I need to print output from the variables $stout ,
I'm using Python's logging mechanism to print output to the screen. I could do
Problem Statement is : Given 2 Dimensional array, print output for example If 4
Basically, this question with a difference... Is it possible to capture print output from
Is there a way to only print or output 10 elements per row inside
hello guys i am try to print the output of two element data simultaneously
I am eager to know how to print the output on a terminal screen

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.