Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?

2018-01-10 Thread Alan Gauld via Tutor
On 10/01/18 20:20, eryk sun wrote: > ... And working with COM via ctypes is also complex, which is why > comtypes exists. Or easier still Pythonwin (aka PyWin32). I far prefer pythonwin over ctypes for any kind of COM work. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.

Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?

2018-01-10 Thread eryk sun
On Wed, Jan 10, 2018 at 12:59 PM, Albert-Jan Roskam wrote: > > I tried: from os.path import _getfullpathname _getfullpathname(r"H:") > 'h:\\path\\to\\folder' import os os.getcwd() > 'h:\\path\\to\\folder' > > I expected h:\ to be \\server\share\foo. You called _getfullpathname

Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?

2018-01-10 Thread Albert-Jan Roskam
From: eryk sun Sent: Wednesday, January 10, 2018 3:56 AM To: tutor@python.org Cc: Albert-Jan Roskam Subject: Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?   On Tue, Jan 9, 2018 at 2:48 PM, Albert-

Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?

2018-01-09 Thread eryk sun
On Tue, Jan 9, 2018 at 2:48 PM, Albert-Jan Roskam wrote: > > I think that it would be a great enhancement if os.realpath would return the > UNC path if > given a mapped drive in Windows, if needed as extended path (prefixed with > "\\?\UNC\"). > That's something I use all the time, unlike symlin

Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?

2018-01-09 Thread Albert-Jan Roskam
From: Tutor on behalf of Steven D'Aprano Sent: Tuesday, January 9, 2018 8:47 AM To: tutor@python.org Subject: Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?   > The Python 3

Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?

2018-01-09 Thread Steven D'Aprano
On Mon, Jan 08, 2018 at 05:08:49PM -0600, boB Stepp wrote: > Hi Steve, > > On Mon, Jan 8, 2018 at 12:47 AM, Steven D'Aprano wrote: > > > As I actually explained in my previous email, the one which has > > disappeared into the aether, ... > > Do you still have the email you sent? I would like t

Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?

2018-01-09 Thread Steven D'Aprano
On Sun, Jan 07, 2018 at 03:07:26AM -0600, boB Stepp wrote: > After some searching I have yet to locate a definition of "canonical > path" that makes sense to me. The dictionary definition of canonical > does not seem to be very helpful in understanding this. Probably the best definition would be

Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?

2018-01-08 Thread eryk sun
On Sun, Jan 7, 2018 at 10:51 AM, Albert-Jan Roskam wrote: > > On Jan 7, 2018 09:08, Steven D'Aprano wrote: >> >> realpath() returns the canonical path of the given filename. It doesn't >> try to locate some actual existing file. > > I always thought that os.path.realpath is the Python equivalent

Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?

2018-01-07 Thread Steven D'Aprano
On Mon, Jan 08, 2018 at 12:39:07AM +, Alan Gauld via Tutor wrote: > To be fair realpath() does do a tiny bit of magic in that it > checks if the file (or any part of the path) is a link (aka > shortcut) and tries to give you the actual path to the > original file - ie it follows the link. As

Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?

2018-01-07 Thread Alan Gauld via Tutor
On 08/01/18 00:17, boB Stepp wrote: >> The os.path module is mostly a string manipulation toolkit. > > This is the critical piece that was eluding me. I assumed that the > actual file system was being queried, checked and expanded as needed. To be fair realpath() does do a tiny bit of magic in

Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?

2018-01-07 Thread boB Stepp
On Sun, Jan 7, 2018 at 8:32 AM, Alan Gauld via Tutor wrote: > On 07/01/18 09:07, boB Stepp wrote: >> clarify this? What is the methodology that os.path.realpath(path) is >> actually following to yield a particular path name? And why does it >> not care if path refers to a real file or not? > > T

Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?

2018-01-07 Thread boB Stepp
On Sun, Jan 7, 2018 at 4:51 AM, Albert-Jan Roskam wrote: > > On Jan 7, 2018 09:08, Steven D'Aprano wrote: >> realpath() returns the canonical path of the given filename. It doesn't >> try to locate some actual existing file. > > I always thought that os.path.realpath is the Python equivalent of

Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?

2018-01-07 Thread Alan Gauld via Tutor
On 07/01/18 09:07, boB Stepp wrote: > clarify this? What is the methodology that os.path.realpath(path) is > actually following to yield a particular path name? And why does it > not care if path refers to a real file or not? The os.path module is mostly a string manipulation toolkit. It checks

Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?

2018-01-07 Thread Albert-Jan Roskam
On Jan 7, 2018 09:08, Steven D'Aprano wrote: > > On Sun, Jan 07, 2018 at 12:49:59AM -0600, boB Stepp wrote: > > > Win7, Python 3.6.2 > > > > If I run a unit test with the following embedded: > > > > print('realpath =', os.path.realpath('test_main.py')) > > > > I get the following in my test outpu

Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?

2018-01-07 Thread boB Stepp
On Sun, Jan 7, 2018 at 2:05 AM, Steven D'Aprano wrote: > On Sun, Jan 07, 2018 at 12:49:59AM -0600, boB Stepp wrote: > >> Win7, Python 3.6.2 >> >> If I run a unit test with the following embedded: >> >> print('realpath =', os.path.realpath('test_main.py')) >> >> I get the following in my test outpu

Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?

2018-01-07 Thread Steven D'Aprano
On Sun, Jan 07, 2018 at 12:49:59AM -0600, boB Stepp wrote: > Win7, Python 3.6.2 > > If I run a unit test with the following embedded: > > print('realpath =', os.path.realpath('test_main.py')) > > I get the following in my test output (Only relevant line is shown): > > Ensure expected list of s