473,386 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Portable /dev/null?

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

Jul 18 '05 #1
3 1772
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
Jul 18 '05 #2
Nicolas Fleury wrote:
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
Jul 18 '05 #3
Josiah Carlson wrote:

Nicolas Fleury wrote:
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.


Note that Nicolas asked for a "portable" approach... clearly neither
NUL nor /dev/null are portable.
Jul 18 '05 #4

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

Similar topics

1
by: JKop | last post by:
Would you classify the following code as "Undefined Behaviour" or as "Non- portable"? signed main() { signed char chedder = 130; } Relevant information:
4
by: aaronfude | last post by:
Hi, Perhaps this is slightly offtopic. Coming into the Windows world from Unix. Is there a reference on writing C++ libraries in a portable way. For example, right now I'm sticking...
3
by: SenderX | last post by:
I am porting a library from msvc++ to gcc and POSIX and was wondering if the following was even close to being portable/c-std: #define MEM_CAST unsigned char* #define MEM_TO_OBJ( m, o...
7
by: Robert Bachmann | last post by:
Two years I wrote a simple cesar encryption program, it worked but it relied on ASCII. So today I tried to make an portable cesar encryption. Please tell me if the code below is really protable. ...
131
by: pemo | last post by:
Is C really portable? And, apologies, but this is possibly a little OT? In c.l.c we often see 'not portable' comments, but I wonder just how portable C apps really are. I don't write...
13
by: bwaichu | last post by:
I have written the program below to just create and populate an html file. I am running into a problem when viewing the created file in vi. I am told by vi that the file does not have an end of...
6
by: Bart Van Loon | last post by:
Hi all, I'm looking for a portable (FreeBSD and Linux) way of getting typical ifconfig information into Python. Some research on the web brought me to Linux only solutions ...
20
by: upperclass | last post by:
Hi, I'm trying to find a decent way of measuring the running time of a long-running program. Say, the running time ranges from several seconds to more than a day. The standard clock()...
6
by: Brendan Miller | last post by:
Hi, I have functions that take a file object and write to it. In some cases I just want to throw out what is written to that file object. I want something like open('/dev/null', 'w'), but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.