Portable /dev/null?

N

Nicolas Fleury

Hi everyone,
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?

Thx and Regards,

Nicolas
 
P

Peter Hansen

Nicolas said:
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

Or something to that effect...

-Peter
 
J

Josiah Carlson

Nicolas said:
Hi everyone,
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?

Thx and Regards,

Nicolas

In Windows you can open the file 'NUL' and it will work the same as
'/dev/null' in *nix.

- Josiah
 
P

Peter Hansen

Josiah said:
In Windows you can open the file 'NUL' and it will work the same as
'/dev/null' in *nix.

Note that Nicolas asked for a "portable" approach... clearly neither
NUL nor /dev/null are portable.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top