Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 765777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:56:28+00:00 2026-05-14T16:56:28+00:00

I recently encountered an IOError writing to a file on NFS. There wasn’t a

  • 0

I recently encountered an IOError writing to a file on NFS. There wasn’t a disk space or permission issue, so I assume this was just a network hiccup. The obvious solution is to wrap the write in a try-except, but I was curious whether the implementation of print and write in Python make either of the following more or less likely to raise IOError:

f_print = open('print.txt', 'w')
print >>f_print, 'test_print'
f_print.close()

vs.

f_write = open('write.txt', 'w')
f_write.write('test_write\n')
f_write.close()

(If it matters, specifically in Python 2.4 on Linux).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T16:56:28+00:00Added an answer on May 14, 2026 at 4:56 pm

    prints are implemented in terms of writes which ultimately result in a write(2) call to the kernel. You could run strace on those two samples and (after wading through a lot of chaff) see the same resultant calls to write(2).

    Indeed, I just did that and omitting 2000+ lines of output yielded:

    execve("/usr/bin/python", ["python", "a.py"], [/* 43 vars */]) = 0
    open("print.txt", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3
    write(3, "test_print\n", 11)            = 11
    close(3)                                = 0
    

    and

    execve("/usr/bin/python", ["python", "b.py"], [/* 43 vars */]) = 0
    open("write.txt", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3
    write(3, "test_write\n", 11)            = 11
    close(3)                                = 0
    

    not a whole lot of difference to be seen, there. Whether the destination file is on a local disk or an NFS mount, the write() call will be the same. The oft-named Nightmare File System will – all other things being equal – fail more often than your local disk.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently encountered a situation where my CouchDB instance used all available disk space
Recently, I encountered a very strange issue, this issue only happens in Windows XP
I recently encountered with this question: How to reduce this expression: s>73?61:60; . The
I recently encountered an issue regarding outputting a PDF generated in iTextSharp into a
I recently encountered a printing issue in Firefox that eventually turned out to be
I've recently encountered an issue with the multi-threaded nature of the BizTalk Mapper and
I have recently encountered an issue that is related to code running in the
I use Rails 3.0.6 with mongoID 2.0.2. Recently I encountered an issue with save!
Recently I encountered this puzzle : int main(){ int arr[7]; int b,c,d,a; a=4; printf(%d,arr[?]);
I recently encountered an issue in a custom Linux kernel (2.6.31.5, x86) driver where

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.