Re: [Python-Dev] Portable and OS-dependent module idea/proposal/brain fart
The proposal then is that importing the platform's module by name will import both the portable and non-portable interface elements. Importing the posix module will import just that portion of the interface that is truly portable across all platforms.
There's one slight problem with this: when you use functionality that is partially portable, i.e. a call that is available on Windows and Unix but not on the Mac. -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm
"Jack" == Jack Jansen
writes:
>> The proposal then is that importing the >> platform's module by name will import both the portable and non-portable >> interface elements. Importing the posix module will import just that >> portion of the interface that is truly portable across all platforms. Jack> There's one slight problem with this: when you use functionality that is Jack> partially portable, i.e. a call that is available on Windows and Unix but not Jack> on the Mac. Agreed. I'm not sure what to do there. Is the intersection of the common OS calls on Unix, Windows and Mac so small as to be useless (or are there some really gotta have functions not in the intersection because they are missing only on the Mac)? Skip
Everybody's right in this debate. I have to type a lot to express objectively my opinion, but better filter my reasoning and just say the conclusion. Having in mind: - what POSIX is - what an OS is - that an OS may or may not comply w/ the POSIX standard, and if it doesn't, it may do so in a couple of years (Windows 3K and PyOS come to mind ;-) - that the os module claims portability amongst the different OSes, mainly regarding their filesystem & process management services, hence it's exposing only a *subset* of the os specific services - the current state of Python It would be nice: - to leave the os module as a common denominator - to have a "unix" module (which could further incorporate the different brands of unix) - to have the posix module capture the fraction of posix functionality, exported from a particular OS specific module, and add the appropriate POSIX propaganda in the docs - to manage to do this, or argue what's wrong with the above -- Vladimir MARANGOZOV | Vladimir.Marangozov@inrialpes.fr http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252
Jack Jansen wrote:
There's one slight problem with this: when you use functionality that is partially portable, i.e. a call that is available on Windows and Unix but not on the Mac.
It gets worse, I think. How about the inconsistencies in POSIX support among *nixes? How about NT being a superset of Win9x? How about NTFS having capabilities that FAT does not? I'd guess there are inconsistencies between Mac flavors, too. The Java approach (if you can't do it everywhere, you can't do it) sucks. In some cases you could probably have the missing functionality (in os) fail silently, but in other cases that would be a disaster. "Least-worst"-is-not-necessarily-"good"-ly y'rs - Gordon
From: "Gordon McMillan"
Jack Jansen wrote:
There's one slight problem with this: when you use functionality that is partially portable, i.e. a call that is available on Windows and Unix but not on the Mac.
It gets worse, I think. How about the inconsistencies in POSIX support among *nixes? How about NT being a superset of Win9x? How about NTFS having capabilities that FAT does not? I'd guess there are inconsistencies between Mac flavors, too.
The Java approach (if you can't do it everywhere, you can't do it) sucks. In some cases you could probably have the missing functionality (in os) fail silently, but in other cases that would be a disaster.
The Python policy has always been "if it's available, there's a standard name and API for it; if it's not available, the function is not defined or will raise an exception; you can use hasattr(os, ...) or catch exceptions to cope if you can live without it." There are a few cases where unavailable calls are emulated, a few where they are made no-ops, and a few where they are made to raise an exception uncoditionally, but in most cases the function will simply not exist, so it's easy to test. --Guido van Rossum (home page: http://www.python.org/~guido/)
Gordon> It gets worse, I think. How about the inconsistencies in POSIX Gordon> support among *nixes? How about NT being a superset of Win9x? Gordon> How about NTFS having capabilities that FAT does not? I'd guess Gordon> there are inconsistencies between Mac flavors, too. To a certain degree I think the C module(s) that interface to the underlying OS's API can iron out differences. In other cases you may have to document minor (known) differences. In still other cases you may have to relegate particular functionality to the OS-dependent modules. Skip Montanaro | http://www.mojam.com/ skip@mojam.com | http://www.musi-cal.com/~skip/ 847-971-7098
participants (5)
-
Gordon McMillan
-
Guido van Rossum
-
Jack Jansen
-
Skip Montanaro
-
Vladimir Marangozov