0

The os.normalized_path outputs . instead of the full path.

import os
echo ".".normalized_path
Alex Craft
  • 13,598
  • 11
  • 69
  • 133

2 Answers2

6

That output is correct - it's "normalised" to the current directory, so it's ".", which is a valid path on *nix. If you want to get the full path, do it like this:

import os
echo ".".normalizedPath().absolutePath()
Optimon
  • 723
  • 1
  • 8
  • 17
5

@Yardanico's answer is still the right one, but this got too long to leave as a comment.

normalizePath has no knowledge of the current working directory and operates on abstract paths, preserving whether the input is absolute or relative. what it does is:

  • remove extra/trailing slashes: 'foo//bar/' => 'foo/bar'
  • resolve double dots: 'foo/../bar' => 'bar', '../foo' => '../foo'
  • remove initial './': './foo' => 'foo'

it does not:

  • remove initial double dots in absolute paths, i.e. '/..' => '/..'
  • convert path delimiters to the native os delimiter.
  • handle os9's idiosyncratic updirs properly
shirleyquirk
  • 1,527
  • 5
  • 21