Difference between untar_data()/'images' vs 'path'/'images'?

Can someone explain to me how this ‘slash’ makes sense (how it works?) when we use untar_data()/‘images’ but not when we do something like ‘folder_1/folder_2’/‘images’?

Think of it like ‘folder_1/folder_2’+‘images’.

untar_data()/‘images’ works because the path that is returned by untar_data() is a true Path object and Path knows that when it sees a slash (/) that it should attach the other end of that to the Path. This code technically is defined in PurePath but that is the parent class of Path. You can confirm this by defining your ‘path’/‘images’ example like this: Path('path')/'images' and it will behave the same way.

On the other hand 'path'/'images' doesn’t work because str types have no logic defined that tell them what to do when a slash is put between them.

Many thanks for a nice explanation! This ‘slash thing’ only works with Path objects or any objects?