Python Forum
Why is this pointing to the objects
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why is this pointing to the objects
#4
Your looking for instance variables.
class A:
 
#     l = [1]
 
    def __init__(self):
        self.l = [1]
 
a = A()
a1 = A()
 
print(id(a.l))
print(id(a1.l))
Output:
2413810246280 2413810246344
Reply


Messages In This Thread
Why is this pointing to the objects - by hshivaraj - Apr-09-2019, 07:22 PM
RE: Why is this pointing to the objects - by Yoriz - Apr-09-2019, 08:00 PM
RE: Why is this pointing to the objects - by Yoriz - Apr-09-2019, 08:21 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Sorting Elements via parameters pointing to those elements. rpalmer 3 2,739 Feb-10-2021, 04:53 PM
Last Post: rpalmer
  Installing Python and pointing it to required libraries hooiberg 2 4,440 May-13-2019, 05:55 PM
Last Post: ebolisa
  What are ways of pointing cross-compiled origin source line for python? wyvogew 2 2,924 Feb-02-2019, 03:16 PM
Last Post: wyvogew

Forum Jump:

User Panel Messages

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