Python Forum
How I can create reference to member of the class instance?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How I can create reference to member of the class instance?
#1
Python 3.7.1

I wrote this class:
class Cycler(object):
    def __init__(self, data):
        self.data = data

    def do(self):
        My_ref = self.data
        My_ref = 2
And now I want create small name to simplify the code. In above code the instance self does not change the value of the variable data (but variable My_ref will now refer to an object of type 'int' with a value of 2).

How I can create writable reference to a member of the class instance?
Reply


Messages In This Thread
How I can create reference to member of the class instance? - by AlekseyPython - Dec-04-2018, 08:46 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How does this code create a class? Pedroski55 6 562 Apr-21-2024, 06:15 AM
Last Post: Gribouillis
  Class member become static Quasar999 1 719 Sep-16-2023, 12:52 PM
Last Post: deanhystad
  can Inner Class reference the Outer Class's static variable? raykuan 6 6,037 Jul-01-2022, 06:34 AM
Last Post: SharonDutton
  Cannot convert the series to <class 'int'> when trying to create new dataframe column Mark17 3 8,627 Jan-20-2022, 05:15 PM
Last Post: deanhystad
  labels.append(self.classes.index(member.find('name').text)) hobbyist 1 1,963 Dec-15-2021, 01:53 PM
Last Post: deanhystad
  Access instance of a class Pavel_47 5 2,147 Nov-19-2021, 10:05 AM
Last Post: Gribouillis
Exclamation win32com: How to pass a reference object into a COM server class Alfalfa 3 4,959 Jul-26-2021, 06:25 PM
Last Post: Alfalfa
  Class Instance angus1964 4 2,497 Jun-22-2021, 08:50 AM
Last Post: angus1964
  Create Generator in the Class quest 1 2,161 Apr-15-2021, 03:30 PM
Last Post: jefsummers
  How to define a variable in Python that points to or is a reference to a list member JeffDelmas 4 2,716 Feb-28-2021, 10:38 PM
Last Post: JeffDelmas

Forum Jump:

User Panel Messages

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