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


Groups > comp.lang.python > #29821

Re: Capitalization for variable that holds a class

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeder2.ecngs.de!ecngs!feeder.ecngs.de!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'classes.': 0.07; '"class"': 0.09; 'pep': 0.09; 'sep': 0.09; 'url:peps': 0.09; 'assume': 0.11; '(when': 0.16; '1:48': 0.16; '24,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'inclined': 0.16; 'point!': 0.16; 'subject:class': 0.16; 'subject:variable': 0.16; 'substitute': 0.16; 'url:pep-0008': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'certainly': 0.17; 'url:dev': 0.17; 'variable': 0.20; "i'd": 0.22; 'example': 0.23; 'header:In- Reply-To:1': 0.25; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'question:': 0.29; 'though.': 0.29; 'sense': 0.31; 'url:python': 0.32; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'doing': 0.35; 'received:209.85': 0.35; 'really': 0.36; 'url:org': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'containing': 0.61; 'between': 0.63; 'more': 0.63; 'making': 0.64; 'therefore': 0.65; 'taking': 0.65; 'real-world': 0.65; 'concept,': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=uSeC2HEvRetSQhZAJMdQT/0Yy33rmNRAhyQQkVb4dVo=; b=pVd+nmojsoirjtojWou7f+CXURLteFNndFtcWEGYJ2hICCymWpu/jR2iPrpIrAtxdV +nYzTBV2OxmVteD8xNnZ5Zq5oH6Hh0UIOV8vB54gBtzk8vrEwWdYdxAUtwkfPUrla+Vi cy9y5UVe6WjfX4cnEVbb3KqFVh/iF4Q0omouaFTP4QYDIlwXOCZmMRxEoyUUUWVQiCUW FiIr2cKuSb2grLz0W/7rmmhTSg24MnWywBWbxdpWd42mYjIyCF0/HdpcUGzdiXlnc/aN N+YufV6VK1qooW0eGQmzlf+E+A/2P3bvDaovglHbPf8R+tQPVHO/kQw4ezj1ddfsmI+k 4k0g==
MIME-Version 1.0
In-Reply-To <CAN1F8qUxbhK8HqRr7RVUQreb2QkAsm+Y9q0LKR0eK1akYbNsLg@mail.gmail.com>
References <CAN1F8qUxbhK8HqRr7RVUQreb2QkAsm+Y9q0LKR0eK1akYbNsLg@mail.gmail.com>
Date Mon, 24 Sep 2012 02:12:25 +1000
Subject Re: Capitalization for variable that holds a class
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
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 <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1124.1348416749.27098.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1348416749 news.xs4all.nl 6940 [2001:888:2000:d::a6]:35795
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:29821

Show key headers only | View raw


On Mon, Sep 24, 2012 at 1:48 AM, Joshua Landau
<joshua.landau.ws@gmail.com> wrote:
> Simple question:
>
> [myClass() for myClass in myClasses]
> vs
> [MyClass() for MyClass in myClasses]
>
> Fight.
>
> (When considering, substitute in a more real-world example like [Token() for
> Token in allTokens] or [token() for token in allTokens])

An interesting point! I assume you're basing this on the PEP 8 recommendation:
http://www.python.org/dev/peps/pep-0008/#class-names

Since there's no difference between a "class" and a "variable
containing a class" or a "pointer to a class" or any other such
concept, it makes sense to capitalize MyClass in your example, if you
are guaranteeing that they're all classes. And certainly a long-lived
variable ought to be named in CapWords. However, all you're really
doing is taking a bunch of callables, calling them, and making a list
of the results. I'd therefore be inclined to _not_ capitalize it. YMMV
though.

ChrisA

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


Thread

Re: Capitalization for variable that holds a class Chris Angelico <rosuav@gmail.com> - 2012-09-24 02:12 +1000
  Re: Capitalization for variable that holds a class Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-23 21:42 +0000

csiph-web