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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T09:53:47+00:00 2026-05-16T09:53:47+00:00

I started using Python in 2001. I loved the simplicity of the language, but

  • 0

I started using Python in 2001. I loved the simplicity of the language, but one feature that annoyed the heck out of me was the / operator, which would bite me in subtle places like

def mean(seq):
    """
    Return the arithmetic mean of a list
    (unless it just happens to contain all ints)
    """
    return sum(seq) / len(seq)

Fortunately, PEP 238 had already been written, and as soon as I found about the new from __future__ import division statement, I started religiously adding it to every .py file I wrote.

But here it is nearly 9 years later and I still frequently see Python code samples that use / for integer division. Is // not a widely-known feature? Or is there actually a reason to prefer the old way?

  • 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-16T09:53:48+00:00Added an answer on May 16, 2026 at 9:53 am

    I think // for truncation is reasonably well known, but people are reluctant to “import from the future” in every module they write.

    The classic approach (using float(sum(seq)) and so on to get a float result, int(...) to truncate an otherwise-float division) is the one you’d use in C++ (and with slightly different syntax in C, Java, Fortran, …), as well as “natively” in every Python release through 2.7 included, so it’s hardly surprising if a lot of people are very used to, and comfortable with, said “classic approach”.

    When Python 3 becomes more widespread and widely used than Python 2, I expect things to change.

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

Sidebar

Related Questions

All, I've just started using Python (v 2.7.1) and one of my first programs
I just started using/learning Python and have some questions. I have a text file
i started using couchdb with python-couchdb recently. The problem is when i use futon
I've recently started using windmill and python to run automated tests of my web
I've just started learning about Gimp scripting using Python, and was wondering, how do
I'm a Python beginner and have just started using packages. When you're calling a
I started by trying to store strings in sqlite using python, and got the
As I'm a novice, I started learning python by writing simple programs using python
Started using Visual Studio 2012 RC since yesterday, We have one WCF solution. Whenever
I started using srbac in Yii. The options that are available: create a role,

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.