Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python for File Systems Navigation Absolutely

Need help with filesystems challenge task 2 of 2.

This question is not to clear to me as I cannot check what the path of the current working directory is... therefore i'm not sure how i'm suppose to complete this challenge.

absolute.py
import os
def absolute(path, root):
    os.path.isabs("projects/python_basics/", "/")

1 Answer

Chris Jones
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Chris Jones
Java Web Development Techdegree Graduate 23,933 Points

Hi Simon!

You don't need to know what the working directory is. The person calling your function will pass a directory in. isabs is able to tell if the path parameter that is passed to it is absolute or not based on whether it starts with a forward slash or back slash (depending on the operating system) (https://docs.python.org/2/library/os.path.html#os.path.isabs).

That said, you've gotten a good start to the challenge. isabs only takes one parameter, the path string, and returns a boolean. Based on whether true or false is returned, you may need to prepend the root parameter to the path parameter before the function returns anything.

I hope that helps some! Let me know if you have any more questions!