Skip to content

Conversation

@i0nut02
Copy link

@i0nut02 i0nut02 commented Apr 9, 2024

No description provided.

@i0nut02
Copy link
Author

i0nut02 commented Apr 10, 2024

it doesn't work for paths like /p1/p2/../p3 and /p1/p2/.., but i think that we don't need this feature for now.

@isnotJack
Copy link

Good implementation of take_parent_dir!
The previous approach "parent = os.path.realpath(os.path.join(path, ".."))" was quite straightforward, but this one is more elegant although it adds some complexity to the algorithm.

return repo
return repo

def take_parent_dir(path):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the recursive solution suggested by the guide. You also mentioned this is not working for all paths.
Readability >>>

if path[i] == "/":
break

if i == 0:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "i" present after the for loops? It seems not. How is this working?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants