473,687 Members | 3,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.
>>import os
for char in 'ABCDEFGHIJKLMN OPQRSTUVWXYZ':
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.
>>import os
for char in 'ABCDEFGHIJKLMN OPQRSTUVWXYZ':
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 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

Dec 18 '06 #1
3 1586
klappnase schrieb:
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.
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
Dec 18 '06 #2

Martin v. Löwis schrieb:
>
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

Dec 19 '06 #3
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:
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.
>import os
for char in 'ABCDEFGHIJKLMN OPQRSTUVWXYZ': 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.
>import os
for char in 'ABCDEFGHIJKLMN OPQRSTUVWXYZ': 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
Jan 24 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
3907
by: John Roth | last post by:
I'm adding a thread for comments on Gerrit Holl's pre-pep, which can be found here: http://tinyurl.com/2578q Frankly, I like the idea. It's about time that all of the file and directory stuff in the os module got objectified properly (or at least with some semblance of OO propriety!) In the issues section:
4
1948
by: Beman Dawes | last post by:
The docs for os.path.exists(), isdir(), and the like, do not describe behavior when an I/O error occurs. Testing on Windows XP SP2 with Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32, on a machine with no a: drive, c: is a hard disk with a top level directory named "path" but without a top level directory named "foo", and d: is a CD drive (with no disc inserted): >>> import os >>> print os.path.exists("c:\\")
4
2992
by: Pierre Quentel | last post by:
os.path.exists(path) returns True if "path" exists But on Windows it also returns True for "path" followed by any number of dots : Python 2.4 (#60, Nov 30 2004, 11:49:19) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.path.exists('Lib/os.py') True # expected
5
7156
by: Rahul Anand | last post by:
Hi, I am facing a problem in accessing a network shared folder. I just wrote a test console application to test the behavior and found that in some cases the .NET does not releases the network connection after accessing the folder. I am not instantiating object which holds the network resource, so in my case no cleanup or dispose is required (assuming). I am just using the Directory.Exists() static method to check whether a directory...
5
7218
by: Tom Vogel | last post by:
Creating a subfolder within my ASP.NET application folder fails with the above error, but only at my hosting provider. The command: Directory.CreateDirectory(path) Path is set to 'D:\appfolder\test2'. ASPNET has full control on the application folder. Any ideas why this fails? - Tom
9
13730
by: Clinton Frankland | last post by:
Hi, On a Windows 2000 Server when attempting to use System.IO.Directory.CreateDirectory(string.concat(Server.MapPath(""), "\verify")) I receive a System.IO.DirectoryNotFoundException error: Could not find a part of the path "D:\". The full path is "D:\hshome\clinton\test.gotchasoft.com\verify" The web is running using impersonation as a user on the local machine.
13
1005
by: Adam | last post by:
Trying to get an asp.net 2.0 app running and am receiving this error. I see a bunch of people with this error on the net, but no solution: Works fine on my local machine, deployed to a server it yields this message. Failed to map the path '/App_GlobalResources/' Stack trace: at System.Web.Hosting.HostingEnvironment.MapPathActual(VirtualPath virtualPath, Boolean permitNull)
34
3955
by: Ben Sizer | last post by:
I've installed several different versions of Python across several different versions of MS Windows, and not a single time was the Python directory or the Scripts subdirectory added to the PATH environment variable. Every time, I've had to go through and add this by hand, to have something resembling a usable Python installation. No such problems on Linux, whether it be Mandrake/Mandriva, Fedora Core, or Kubuntu. So why is the Windows...
18
3515
by: Aaron Gray | last post by:
Has anyone got a code snippet to separate out the path components, ie drive, path, filename, and extension ? Many thanks in advance, Aaron
0
8947
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8781
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8784
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6453
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4321
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4543
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2964
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2214
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1948
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.