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 927825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:54:50+00:00 2026-05-15T19:54:50+00:00

Are there situations in which sys.stdout.write() is preferable to print ? ( Examples: better

  • 0

Are there situations in which sys.stdout.write() is preferable to print?

(Examples: better performance; code that makes more sense)

  • 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-15T19:54:50+00:00Added an answer on May 15, 2026 at 7:54 pm

    print is just a thin wrapper that formats the inputs (modifiable, but by default with a space between args and newline at the end) and calls the write function of a given object. By default this object is sys.stdout, but you can pass a file using the “chevron” form. For example:

    print >> open('file.txt', 'w'), 'Hello', 'World', 2+3
    

    See: https://docs.python.org/2/reference/simple_stmts.html?highlight=print#the-print-statement


    In Python 3.x, print becomes a function, but it is still possible to pass something other than sys.stdout thanks to the fileargument.

    print('Hello', 'World', 2+3, file=open('file.txt', 'w'))
    

    See https://docs.python.org/3/library/functions.html#print


    In Python 2.6+, print is still a statement, but it can be used as a function with

    from __future__ import print_function
    

    Update: Bakuriu commented to point out that there is a small difference between the print function and the print statement (and more generally between a function and a statement).

    In case of an error when evaluating arguments:

    print "something", 1/0, "other" #prints only something because 1/0 raise an Exception
    
    print("something", 1/0, "other") #doesn't print anything. The function is not called
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(See question below for more context): Are there any situations in which <machineKey validationKey=AutoGenerate,IsolateApps
Are there situations in which this method would not be called? I'm thinking to
I was told there are multiple situations in which initialization list must be used
Are there situations where a UIAlertView is better to use than a UIActionSheet? What
Possible Duplicate: String concatenation vs array implode in PHP there are situations in which
Possible Duplicate: In which situations do we need to write the __autoreleasing ownership qualifier
As teams work to develop software in parallel, there are situations in which the
Because there are multiple situations in which I would want to pop a view
Situation: There are several entities in a simulated environment, which has an artificial notion
I have a following situation in my project. There are some tag values which

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.