0

I am new to python and trying to understand the _full_path from this example.

  def _full_path(self, partial):
        if partial.startswith("/"):
            partial = partial[1:]
        path = os.path.join(self.root, partial)
        return path

What does the function do? Specifically, what does this line do?

 partial = partial[1:]

It seems like some kind of list manipulation -- but I can't find syntax like that in this document.

What is the root property of self that is getting called?

Can somebody explain a little bit about what is happening in that code.

bernie2436
  • 22,841
  • 49
  • 151
  • 244

2 Answers2

3

Because os.path.join will take later path start with '/' as base, try this:

print os.path.join('/a', '/b/')

it return '/b/', so you have to check and remove begin slash when you join path.

str is a sequence type, check here: http://docs.python.org/2/library/stdtypes.html#sequence-types-str-unicode-list-tuple-bytearray-buffer-xrange

PasteBT
  • 2,128
  • 16
  • 17
1

That line drops the starting "/".

The function itself gives back the "full path".

Gerifield
  • 403
  • 5
  • 12