Python Forum
how to return a reference to an object?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to return a reference to an object?
#7
If the object is immutable, it cannot be "passed by reference". No changes can be made to the object, so any operation, like incrementing, creates a new object. If the object is mutable, it is always "passed by reference". Changes made to the object will be seen by anyone who references the object.

Sounds like you need to create a mutable object that behaves like a number, at least some of the time, but can have it's "value" changed.
Reply


Messages In This Thread
RE: how to return a reference to an object? - by deanhystad - Jun-07-2023, 03:26 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  This result object does not return rows. It has been closed automatically dawid294 6 1,867 Mar-30-2024, 03:08 AM
Last Post: NolaCuriel
Exclamation win32com: How to pass a reference object into a COM server class Alfalfa 3 5,157 Jul-26-2021, 06:25 PM
Last Post: Alfalfa
  Pass by object reference when does it behave like pass by value or reference? mczarnek 2 2,705 Sep-07-2020, 08:02 AM
Last Post: perfringo
  isinstance() always return true for object type check Yoki91 2 2,752 Jul-22-2020, 06:52 PM
Last Post: Yoki91
  Object reference in Dict - not resolved at runtime benthomson 2 1,966 Apr-02-2020, 08:50 AM
Last Post: benthomson
  set a new object node in a linked list via reference oloap 2 2,218 Mar-13-2020, 09:45 PM
Last Post: oloap
  Return a value when I equal an object from a class ihouses 4 3,164 Jul-10-2019, 02:44 AM
Last Post: SheeppOSU
  TypeError: cannot create weak reference to 'str' object Harryjduke 2 8,965 Mar-09-2019, 04:59 PM
Last Post: Harryjduke
  Return Object Created from Multiple Classes emerger 3 3,250 Oct-18-2018, 02:14 AM
Last Post: emerger

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020