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

  • Home
  • SEARCH
  • 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 9274199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:17:58+00:00 2026-06-18T16:17:58+00:00

I have finally switched from % to the .format() string formatting operator in my

  • 0

I have finally switched from % to the .format() string formatting operator in my 2.x code in order to make it easier to migrate to 3.x in future. It was a bit surprising to find out that not only the %-style formatting remains in Py3, but it is widely used in the standard library code. It seems logical, because writing '(%s)' % variable is a bit shorter and maybe easier to comprehend than '({})'.format(variable). But I’m still in doubt. Is it proper (pythonic?) to use both approaches in the code?
Thank you.

  • 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-06-18T16:17:59+00:00Added an answer on June 18, 2026 at 4:17 pm

    Python 3.2 documentation said that, % will eventually go away.

    http://docs.python.org/3.2/tutorial/inputoutput.html#old-string-formatting

    Since str.format() is quite new, a lot of Python code still uses the %
    operator. However, because this old style of formatting will
    eventually be removed from the language, str.format() should generally
    be used.

    But as @regilero says, the sentence is gone from 3.3, which might suggest it’s not actually the case. There are some conversations here that suggest the same thing.

    As of Python 3.4 the paragraph 7.1.1 reads:

    The % operator can also be used for string formatting. It interprets
    the left argument much like a sprintf()-style format string to be
    applied to the right argument, and returns the string resulting from
    this formatting operation.

    See also Python 3.4 4.7.2 printf-style String Formatting.

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

Sidebar

Related Questions

String a=(Yeahhhh) I have finally made it to the (top); Given above String, there
We have finally put our giant VB.net 2.0 Web Application into a code freeze
I have finally started upgrading my Rails apps from 2.3.8 to 3.1.0. I was
I have finally started to test my code while developing iOS applications. However, I
I have finally made a production worthy app with play, and use the play
I have finally decided to go with the Entity Framework since it has the
I have finally worked out how to get stdin and stdout to pipe between
I have finally got in my mind what worried me about Dependency Injection and
I have finally started messing around with creating some apps that work with RESTful
I have finally managed to get javan-whenever gem working on my site5 server, and

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.