0

Suppose I have

lyst = [obj1, obj2, obj3]

Is there a way to call lyst some way by only using one of the objects in the list (like obj1)?

richzli
  • 131
  • 8
  • 5
    Not unless that object explicitly has a reference to the list it is contained in. Whatever you are trying to do can certainly be done in a cleaner way. Can you add in more details? – UltraInstinct Jun 25 '16 at 21:48
  • 1
    So what if there is another list referencing `obj1`? Or any other type of object? `lyst` indices are *references*, and while there are ways to locate `lyst` from `obj1` this doesn't give you any way to distinguish between `lyst` and any other `list` object. – Martijn Pieters Jun 25 '16 at 21:53
  • http://stackoverflow.com/questions/4341942/how-can-i-get-a-list-of-references-of-an-object-in-python This question explains quite abit about why it's not very feasible – Yarnspinner Jun 26 '16 at 04:21
  • This seems to be an [XY Problem](http://meta.stackexchange.com/a/66378). What are you trying to do? – Jan Christoph Terasa Jun 26 '16 at 12:45

0 Answers0