Re: how to get os.py to use an ./ntpath.py instead of Lib/ntpath.py

2012-11-09 Thread Aahz
In article , Thomas Rachel wrote: >Am 11.09.2012 05:46 schrieb Steven D'Aprano: >> >> Good for you. (Sorry, that comes across as more condescending than it is >> intended as.) Monkey-patching often gets used for quick scripts and tiny >> pieces of code because it works. >> >> Just beware that if

Re: how to get os.py to use an ./ntpath.py instead of Lib/ntpath.py

2012-09-11 Thread Thomas Rachel
Am 11.09.2012 05:46 schrieb Steven D'Aprano: Good for you. (Sorry, that comes across as more condescending than it is intended as.) Monkey-patching often gets used for quick scripts and tiny pieces of code because it works. Just beware that if you extend that technique to larger bodies of code,

Re: how to get os.py to use an ./ntpath.py instead of Lib/ntpath.py

2012-09-11 Thread Dave Angel
On 09/11/2012 03:13 PM, ruck wrote: > > > I'm not sure how I could have known that ntpath was already imported, since > *I* didn't import it, but that was the key to my confusion. > import sys print sys.modules -- DaveA -- http://mail.python.org/mailman/listinfo/python-list

Re: how to get os.py to use an ./ntpath.py instead of Lib/ntpath.py

2012-09-11 Thread Chris Angelico
On Wed, Sep 12, 2012 at 5:13 AM, ruck wrote: > I'm not sure how I could have known that ntpath was already imported, since > *I* didn't import it, but that was the key to my confusion. One way to find out is to peek at the cache. >>> import sys >>> sys.modules There are quite a few of them in

Re: how to get os.py to use an ./ntpath.py instead of Lib/ntpath.py

2012-09-11 Thread ruck
On Tuesday, September 11, 2012 12:21:24 AM UTC-7, Tim Golden wrote: > And so it does, but you'll notice from the MSDN docs that the \\? > syntax must be supplied as a Unicode string, which os.listdir > will do if you pass it a Python unicode object and not otherwise: I was saying os.listdir doesn'

Re: how to get os.py to use an ./ntpath.py instead of Lib/ntpath.py

2012-09-11 Thread Tim Golden
On 11/09/2012 04:46, Steven D'Aprano wrote: > On Mon, 10 Sep 2012 15:22:05 -0700, ruck wrote: > >> On Monday, September 10, 2012 1:16:13 PM UTC-7, Steven D'Aprano wrote: > [...] >>> That's not so much a workaround as the officially supported API for >>> dealing with the situation you are in. Why d

Re: how to get os.py to use an ./ntpath.py instead of Lib/ntpath.py

2012-09-10 Thread Steven D'Aprano
On Mon, 10 Sep 2012 15:22:05 -0700, ruck wrote: > On Monday, September 10, 2012 1:16:13 PM UTC-7, Steven D'Aprano wrote: [...] > > That's not so much a workaround as the officially supported API for > > dealing with the situation you are in. Why don't you just prepend a > > '?' to paths like they

Re: how to get os.py to use an ./ntpath.py instead of Lib/ntpath.py

2012-09-10 Thread ruck
On Monday, September 10, 2012 1:16:13 PM UTC-7, Steven D'Aprano wrote: > On Mon, 10 Sep 2012 10:25:29 -0700, ruck wrote: > > > > > In Python 2.7.2 on Windows 7, > > > > > > os.walk() uses isdir(), > > > which comes from os.path, > > > which really comes from ntpath.py, > > > which really c

Re: how to get os.py to use an ./ntpath.py instead of Lib/ntpath.py

2012-09-10 Thread Steven D'Aprano
On Mon, 10 Sep 2012 10:25:29 -0700, ruck wrote: > In Python 2.7.2 on Windows 7, > > os.walk() uses isdir(), > which comes from os.path, > which really comes from ntpath.py, > which really comes from genericpath.py > > I want os.walk() to use a modified isdir() on my Windows 7. Not knowing > any

how to get os.py to use an ./ntpath.py instead of Lib/ntpath.py

2012-09-10 Thread ruck
In Python 2.7.2 on Windows 7, os.walk() uses isdir(), which comes from os.path, which really comes from ntpath.py, which really comes from genericpath.py I want os.walk() to use a modified isdir() on my Windows 7. Not knowing any better, it seems to me like ntpath.py would be a good place to int