Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #66741

Commonly-used names in the Python standard library

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'subject:Python': 0.06; 'sys': 0.07; 'referenced': 0.09; 'references,': 0.09; 'used.': 0.09; 'python': 0.11; 'random': 0.14; 'averaging': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'ignoring': 0.16; 'keyword,': 0.16; 'subject:library': 0.16; 'surprises': 0.16; 'code.': 0.18; 'library': 0.18; 'variable': 0.18; 'to:name:python- list@python.org': 0.22; 'print': 0.22; 'library,': 0.24; 'fairly': 0.24; 'script': 0.25; 'values': 0.27; 'function': 0.29; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'asked': 0.31; 'commonly': 0.31; 'extensively': 0.31; 'names.': 0.31; 'responded': 0.31; 'file': 0.32; 'there.': 0.32; 'subject:the': 0.34; 'common': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'two': 0.37; 'needed': 0.38; 'to:addr:python-list': 0.38; 'that,': 0.38; 'short': 0.38; 'use.': 0.39; 'to:addr:python.org': 0.39; 'most': 0.60; 'new': 0.61; 'name': 0.63; 'more': 0.64; 'total': 0.65; 'steady': 0.68; 'obvious': 0.74; '2255': 0.84; '40%': 0.84; 'are...': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=bnwAQPjzljdRG7H2BqqIVPpxlsJZjUTWkqv+wPaMbe0=; b=GP7UktL37eQ/pi+NYgqEvQi2+Vg2aNztNn0TLrKTVkOvolbwyIjLRxch2711ZpXcFm ylmsVwFfKkW5lu3kFfVk+kAJI/VRzSvrMQR3gIPImK/hsF0UUNR1/t6ulGm4/B5VJEoZ gwxp1ekk25ir8yxs28W8WVP3ABc70/at+TgHvMjn28TgU6G1GUEEY6YxwX63//bhl0li kRmf/FMIe9k45Llynx0ETW98F+gGa5Vl+GDA2y6IHj12ZYmYqZw9+M15xXz+0eXuDL0p Cn3tbhgDZQGrKz3gB+Ut+85I9F0AWU3zHNczy30K5z1j3howB1+yYxlgtWpFHQ4MYcL4 YImQ==
MIME-Version 1.0
X-Received by 10.68.98.3 with SMTP id ee3mr861930pbb.31.1392889150208; Thu, 20 Feb 2014 01:39:10 -0800 (PST)
Date Thu, 20 Feb 2014 20:39:10 +1100
Subject Commonly-used names in the Python standard library
From Chris Angelico <rosuav@gmail.com>
To "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.7178.1392889158.18130.python-list@python.org> (permalink)
Lines 40
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1392889158 news.xs4all.nl 2882 [2001:888:2000:d::a6]:43025
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:66741

Show key headers only | View raw


In working on a proposal that might result in the creation of a new
keyword, I needed to ascertain what names were used extensively in
existing Python code. Out of random curiosity, I asked my script what
names were the most commonly used. The script responded with 21854
names and a total of 297164 references, averaging 13-14 refs per name.

A good number of names are referenced just once - set and never
referenced. They're there for applications to use. That takes out 6217
names. But I'm more interested in the ones that see a lot of use.

By far the most common name is 'self', for obvious reasons; after
that, it's a fairly steady drop-off. The most popular names in the
standard library are... *drumroll*

45298 - self
3750 - os
3744 - name
3166 - i
3140 - s
2685 - value
2648 - a
2451 - len
2348 - c
2331 - sys
2255 - b
2238 - line
2132 - print
2131 - x

Few surprises there. The os and sys modules are used extensively, and
short variable names are reused frequently. To the print-detractors:
That's two thousand uses in the standard library, more than any other
single function bar 'len'! (And by the way, this is ignoring any file
with /test/ in the name.)

I find the pairing of 'name' and 'value' interesting. There are 40%
more names than values in Python, apparently. And on that bombshell,
as they say on Top Gear, it's time to end!

ChrisA

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Commonly-used names in the Python standard library Chris Angelico <rosuav@gmail.com> - 2014-02-20 20:39 +1100
  Re: Commonly-used names in the Python standard library Marko Rauhamaa <marko@pacujo.net> - 2014-02-20 12:22 +0200
    Re: Commonly-used names in the Python standard library Chris Angelico <rosuav@gmail.com> - 2014-02-20 21:43 +1100
      Re: Commonly-used names in the Python standard library Marko Rauhamaa <marko@pacujo.net> - 2014-02-20 13:28 +0200
        Re: Commonly-used names in the Python standard library Chris Angelico <rosuav@gmail.com> - 2014-02-20 22:37 +1100
        Re: Commonly-used names in the Python standard library Chris Angelico <rosuav@gmail.com> - 2014-02-20 22:47 +1100
          Re: Commonly-used names in the Python standard library Marko Rauhamaa <marko@pacujo.net> - 2014-02-20 14:09 +0200
            Re: Commonly-used names in the Python standard library Chris Angelico <rosuav@gmail.com> - 2014-02-20 23:19 +1100
              Re: Commonly-used names in the Python standard library Marko Rauhamaa <marko@pacujo.net> - 2014-02-20 14:46 +0200
                Re: Commonly-used names in the Python standard library Chris Angelico <rosuav@gmail.com> - 2014-02-21 00:34 +1100
                Re: Commonly-used names in the Python standard library Marko Rauhamaa <marko@pacujo.net> - 2014-02-20 17:14 +0200
                Re: Commonly-used names in the Python standard library Chris Angelico <rosuav@gmail.com> - 2014-02-21 02:48 +1100
                Re: Commonly-used names in the Python standard library Marko Rauhamaa <marko@pacujo.net> - 2014-02-20 18:26 +0200
                Re: Commonly-used names in the Python standard library Chris Angelico <rosuav@gmail.com> - 2014-02-21 03:36 +1100
                Re: Commonly-used names in the Python standard library 88888 Dihedral <dihedral88888@gmail.com> - 2014-02-21 12:57 -0800
                Re: Commonly-used names in the Python standard library Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-21 06:49 +0000
            Re: Commonly-used names in the Python standard library Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-21 06:43 +0000
    Re: Commonly-used names in the Python standard library Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-21 06:59 +0000
      Re: Commonly-used names in the Python standard library Chris Angelico <rosuav@gmail.com> - 2014-02-21 18:10 +1100
      Re: Commonly-used names in the Python standard library Marko Rauhamaa <marko@pacujo.net> - 2014-02-21 09:21 +0200
        Re: Commonly-used names in the Python standard library Chris Angelico <rosuav@gmail.com> - 2014-02-21 19:21 +1100
          Re: Commonly-used names in the Python standard library Marko Rauhamaa <marko@pacujo.net> - 2014-02-21 12:26 +0200
            Re: Commonly-used names in the Python standard library Chris Angelico <rosuav@gmail.com> - 2014-02-21 21:49 +1100
              Re: Commonly-used names in the Python standard library Marko Rauhamaa <marko@pacujo.net> - 2014-02-21 14:03 +0200
                Re: Commonly-used names in the Python standard library Ethan Furman <ethan@stoneleaf.us> - 2014-02-21 11:16 -0800
        Re: Commonly-used names in the Python standard library Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-21 09:12 +0000
  Re: Commonly-used names in the Python standard library Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-21 06:51 +0000
    Re: Commonly-used names in the Python standard library Chris Angelico <rosuav@gmail.com> - 2014-02-21 18:02 +1100

csiph-web