What exactly label_from_func function does (lesson3). Why it changes other instance variable

I have problems understanding why by reassigning instance variable with the return value of the method another instance variable is also changed. I found this occurs in part of the code from data_block.py (line 478):

self.train = ft(*args, from_item_lists=True, **kwargs)

I have changed this to:

 print("before train", self.x)
 self.train = ft(*args, from_item_lists=True, **kwargs)
 print("after train", self.x)

And receive following output:

before train None
after train PointsItemList (15193 items)
Image (3, 480, 640),Image (3, 480, 640),Image (3, 480, 640),Image (3, 480, 640),Image (3, 480, 640)
Path: /home/ja/.fastai/data/biwi_head_pose

Why self.x changed while we were reassigning self.train?

Well, I found it… sorry for asking a stupid question- just in case somebody was as blind as me:
self.x in this case actually isn’t existing at all. The reason it is printed lies in the getattr method- the same one I’ve seen this strange occurrence. While calling self.x x is not present in ItemLists class and ft = getattr(self.train, k) is called, thus printing actually self.train.x.

Fell free to delete this topic if none needs it.

1 Like