On 09May2013 11:30, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: | On Thu, 09 May 2013 18:23:31 +1000, Cameron Simpson wrote: | | > On 09May2013 19:54, Greg Ewing <greg.ew...@canterbury.ac.nz> wrote: | > | Steven D'Aprano wrote: | > | > There is no sensible use-case for creating a file WITHOUT OPENING | > | > it. What would be the point? | > | | > | Early unix systems often used this as a form of locking. | > | > Not just early systems: it's a nice lightweight method of making a | > lockfile even today if you expect to work over NFS, where not that many | > things are synchronous. You OPEN A FILE with "0" modes | | [emphasis added] | This is all very well and good, but for the life of me, I cannot see how | opening a file is a good example of not opening a file. Perhaps it is a | Zen thing, like the sound no spoon makes when you don't tap it against a | glass that isn't there.
Because a file usually does not exist in isolation (yes sometimes we want an isolated file). Files usually exist in the filesystem, which is a namespace. And this is effectively a namespace operation, not a data storage operation. Of course, I can take this the other way: just because I opened it with a 0 mode field doesn't mean _I_, the opener, cannot read/write it. I've got an open file handle... A race free way to make a scratch file in a shared area, for example. The point is probably that a file isn't merely a feature free byte storage container; in the real world they usually come with all sorts of features like names and permissions. Those features will always imply creative uses. Anyway, this has little to do with your antipattern (about which I'm not totally convinced anyway unless it is a rule of thumb or code smell). It might apply to a Platonicly ideal file, but real files have more than one use case. Cheers, -- Cameron Simpson <c...@zip.com.au> I just kept it wide-open thinking it would correct itself. Then I ran out of talent. - C. Fittipaldi -- http://mail.python.org/mailman/listinfo/python-list