Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Cyborg)
  • No Skin
Collapse
Brand Logo

CIRCLE WITH A DOT

  1. Home
  2. Uncategorized
  3. A colleague of mine was shocked to learn that `del obj` doesn't actually delete the object, just the reference to it.

A colleague of mine was shocked to learn that `del obj` doesn't actually delete the object, just the reference to it.

Scheduled Pinned Locked Moved Uncategorized
python
5 Posts 4 Posters 0 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • brass75@twit.socialB This user is from outside of this forum
    brass75@twit.socialB This user is from outside of this forum
    brass75@twit.social
    wrote last edited by
    #1

    A colleague of mine was shocked to learn that `del obj` doesn't actually delete the object, just the reference to it. So if you do:

    x = obj
    y = obj
    del x

    y and obj still exist with y referencing obj. x no longer exists.

    #Python

    stylus@social.afront.orgS grim_elsewhere@lgbtqia.spaceG cazabon@mindly.socialC 3 Replies Last reply
    0
    • brass75@twit.socialB brass75@twit.social

      A colleague of mine was shocked to learn that `del obj` doesn't actually delete the object, just the reference to it. So if you do:

      x = obj
      y = obj
      del x

      y and obj still exist with y referencing obj. x no longer exists.

      #Python

      stylus@social.afront.orgS This user is from outside of this forum
      stylus@social.afront.orgS This user is from outside of this forum
      stylus@social.afront.org
      wrote last edited by
      #2

      @brass75 otherwise somebody would del 3 and then where does that leave us.

      brass75@twit.socialB 1 Reply Last reply
      0
      • stylus@social.afront.orgS stylus@social.afront.org

        @brass75 otherwise somebody would del 3 and then where does that leave us.

        brass75@twit.socialB This user is from outside of this forum
        brass75@twit.socialB This user is from outside of this forum
        brass75@twit.social
        wrote last edited by
        #3

        @stylus Down 3 in the bottom of the nth.

        1 Reply Last reply
        0
        • brass75@twit.socialB brass75@twit.social

          A colleague of mine was shocked to learn that `del obj` doesn't actually delete the object, just the reference to it. So if you do:

          x = obj
          y = obj
          del x

          y and obj still exist with y referencing obj. x no longer exists.

          #Python

          grim_elsewhere@lgbtqia.spaceG This user is from outside of this forum
          grim_elsewhere@lgbtqia.spaceG This user is from outside of this forum
          grim_elsewhere@lgbtqia.space
          wrote last edited by
          #4

          @brass75 I've done my fair share wrestling the alligator that is the python garbage collector. Call my crazy, but this is why I like clear reference denotation in C.

          1 Reply Last reply
          0
          • brass75@twit.socialB brass75@twit.social

            A colleague of mine was shocked to learn that `del obj` doesn't actually delete the object, just the reference to it. So if you do:

            x = obj
            y = obj
            del x

            y and obj still exist with y referencing obj. x no longer exists.

            #Python

            cazabon@mindly.socialC This user is from outside of this forum
            cazabon@mindly.socialC This user is from outside of this forum
            cazabon@mindly.social
            wrote last edited by
            #5

            @brass75

            What did your colleague think `y` would be after deleting x?

            1 Reply Last reply
            2
            0
            • R relay@relay.publicsquare.global shared this topic
              R relay@relay.mycrowd.ca shared this topic
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups