Portable /dev/null?
Peter Hansen
peter at engcorp.com
Tue Jan 27 17:47:12 EST 2004
Nicolas Fleury wrote:
>
> Is there an object in some standard library that would be the portable
> equivalent of "file('/dev/null','w')" or do I have to create my own
> class and object to do it? If it doesn't exist, do you think it would
> be a good idea to have such an object in a standard library?
Probably considered too simple to bother putting in the standard library.
class nullFile:
def write(self, data):
pass
>>> n = nullFile()
>>> print >>n, "this goes nowhere"
Or something to that effect...
-Peter
More information about the Python-list
mailing list