Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old December 18th, 2006, 12:35 AM
klappnase
Guest
 
Posts: n/a
Default New os.path.exists() behavior - bug or feature?

Hi all,
yesterday I installed Python-2.5 and python-2.4.4 on my windows2k box.
When trying to use os.path.exists() to detect which drives are present
on the system I noticed that
these behave differently:

Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)]
on win32
Type "copyright", "credits" or "license()" for more information.
Quote:
Quote:
Quote:
>>import os
>>for char in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
if os.path.exists('%s:\\' % char):
print '%s:\\' % char


A:\
C:\
D:\
E:\
Quote:
Quote:
Quote:
>>>
###########################################

Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
(Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
Quote:
Quote:
Quote:
>>import os
>>for char in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
if os.path.exists('%s:\\' % char):
print '%s:\\' % char


C:\
Quote:
Quote:
Quote:
>>>
When I insert a floppy into A: os.path.exists('A:\\') will return True
on Python-2.5, too.
Does anyone know, is this inconsistent behavior a bug or a new feature?

I also noticed that the Tix binaries are no longer present in 2.5, does
anyone know if it is
planned to remove them pemanently?

Thanks in advance

Michael

  #2  
Old December 18th, 2006, 11:45 AM
=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
Guest
 
Posts: n/a
Default Re: New os.path.exists() behavior - bug or feature?

klappnase schrieb:
Quote:
When I insert a floppy into A: os.path.exists('A:\\') will return True
on Python-2.5, too.
Does anyone know, is this inconsistent behavior a bug or a new feature?
Neither, nor. In both cases, the operating system is asked, and gives
this answer. However, in the Windows API, there is no "exists" function
(nor is there on Unix); instead, exists is implemented by calling
several underlying functions. The precise set of functions used did
change between 2.4 and 2.5.

It is quite difficult to investigate the precise nature of the change
that leads to this change in observable behavior. If you think this is
a bug, it would be best if you could also investigate a patch.
Quote:
I also noticed that the Tix binaries are no longer present in 2.5, does
anyone know if it is
planned to remove them pemanently?
That was a mistake, I'll add it back in 2.5.1.

Regards,
Martin
  #3  
Old December 19th, 2006, 04:55 PM
klappnase
Guest
 
Posts: n/a
Default Re: New os.path.exists() behavior - bug or feature?


Martin v. Löwis schrieb:
Quote:
>
Neither, nor. In both cases, the operating system is asked, and gives
this answer. However, in the Windows API, there is no "exists" function
(nor is there on Unix); instead, exists is implemented by calling
several underlying functions. The precise set of functions used did
change between 2.4 and 2.5.
>
It is quite difficult to investigate the precise nature of the change
that leads to this change in observable behavior. If you think this is
a bug, it would be best if you could also investigate a patch.
>
I don't know if it is a bug; at least it is backwards incompatible,
which I think is never a good thing.
Unfortunately, I am afraid writing a patch is beyond my expertise :(

Regards

Michael

  #4  
Old January 24th, 2007, 11:25 PM
Martin Miller
Guest
 
Posts: n/a
Default Re: New os.path.exists() behavior - bug or feature?

FWIW, your code works correctly for me in all respects with Python 2.5
on Windows XP Pro.
I no longer have Python 2.4.x installed, so can't easily do a
comparison.

Perhaps the problem has something to do with Python 2.5 with Windows
2K.

-Martin


On Dec 17 2006, 4:29 pm, "klappnase" <klappn...@web.dewrote:
Quote:
Hi all,
yesterday I installed Python-2.5 and python-2.4.4 on my windows2k box.
When trying to use os.path.exists() to detect which drives are present
on the system I noticed that
these behave differently:
>
Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)]
on win32
Type "copyright", "credits" or "license()" for more information.
>
Quote:
Quote:
>import os
>for char in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ': if os.path.exists('%s:\\' % char):
print '%s:\\' % char
>
A:\
C:\
D:\
E:\
>
###########################################
>
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
(Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>
Quote:
Quote:
>import os
>for char in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ': if os.path.exists('%s:\\' % char):
print '%s:\\' % char
>
C:\
>
When I insert a floppy into A: os.path.exists('A:\\') will return True
on Python-2.5, too.
Does anyone know, is this inconsistent behavior a bug or a new feature?
>
I also noticed that theTixbinaries are no longer present in 2.5, does
anyone know if it is
planned to remove them pemanently?
>
Thanks in advance
>
Michael
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles