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


Groups > comp.lang.python > #12413

Re: is there any principle when writing python function

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.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.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'think,': 0.05; 'agree,': 0.07; 'imply': 0.07; 'names.': 0.07; 'subject:when': 0.07; 'python': 0.08; 'instance.': 0.09; 'namespace': 0.09; 'referenced': 0.09; 'subject:python': 0.11; 'am,': 0.12; 'hopefully': 0.15; 'preference': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; "function's": 0.16; 'meaningful,': 0.16; 'meaningless': 0.16; 'neat': 0.16; 'represents.': 0.16; 'subject:function': 0.16; 'subject:writing': 0.16; 'have,': 0.16; 'this:': 0.16; 'wrote:': 0.16; 'functions,': 0.18; 'received:209.85.210.174': 0.18; 'received:mail- iy0-f174.google.com': 0.18; '(which': 0.19; 'header:In-Reply- To:1': 0.22; 'tue,': 0.23; 'module,': 0.23; 'aug': 0.24; 'code': 0.25; "i'm": 0.27; 'function': 0.27; 'fine.': 0.29; 'message- id:@mail.gmail.com': 0.29; 'module': 0.30; 'splitting': 0.30; 'class': 0.30; 'chris': 0.32; 'words,': 0.32; 'does': 0.32; 'usually': 0.32; 'probably': 0.33; "can't": 0.33; 'to:addr:python- list': 0.33; 'named': 0.33; 'house,': 0.34; 'function.': 0.34; 'reference': 0.35; 'object': 0.35; 'explain': 0.36; 'useful': 0.36; 'but': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'should': 0.38; 'subject:: ': 0.39; 'characters': 0.39; 'to:addr:python.org': 0.39; "it's": 0.40; 'your': 0.61; 'unique': 0.62; 'you.': 0.62; 'town': 0.63; 'believe': 0.65; 'ever': 0.65; 'brother': 0.67; '30,': 0.74; '12:52': 0.84; 'distinguish': 0.84; 'proportional': 0.84; 'subject:any': 0.84; 'subject:there': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=gpGsTaJygK7OrQlxg4Qku+EPz5KHIM7/xcuGg3cH5Hk=; b=Xn1Q+hDwuX/9gQ7BSxdgnBdfyWGJ8hHMUUlAOGAxfbYUSHj4j0Rcg4JnnEMfKsNwgh sVW0HhlO49Kq544oZo7qzPkiWEg+oZV5FbYH3W5A0Gn2HM5KbsWGgFjFyROd0U407YWC FUs+noT4K1hP/8jd77LKNJhT1IXBnl/cPc82E=
MIME-Version 1.0
In-Reply-To <9c1ndoFj9iU10@mid.individual.net>
References <mailman.346.1314100765.27778.python-list@python.org> <c2fe3168-92b1-46a1-a176-0914f0ba9579@19g2000vbv.googlegroups.com> <roy-957AF6.07155226082011@news.panix.com> <7b47ca17-d3f1-4d91-91d1-98421e8708cd@ea4g2000vbb.googlegroups.com> <ifP5q.1635$EP3.888@newsfe05.iad> <mailman.446.1314375037.27778.python-list@python.org> <9c1ndoFj9iU10@mid.individual.net>
Date Tue, 30 Aug 2011 04:20:49 +1000
Subject Re: is there any principle when writing python function
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.12
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.550.1314642053.27778.python-list@python.org> (permalink)
Lines 33
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1314642053 news.xs4all.nl 2453 [2001:888:2000:d::a6]:44803
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:12413

Show key headers only | View raw


On Tue, Aug 30, 2011 at 12:52 AM, Neil Cerutti <neilc@norwich.edu> wrote:
>> I would split the function only when both halves (caller and
>> callee) can be given short and useful names - if you can't
>> explain what a block of code does in a few words, it's probably
>> a poor choice for splitting out into a function.
>
> I agree, except for the implied unconditional preference for
> short names. I believe the length of a name should usually be
> proportional to the scope of the object it represents.

Oh,I definitely prefer short names to this:
http://thedailywtf.com/Articles/Double-Line.aspx

"Short" is a relative term. If the function's name is 20 characters
long and meaningful, that's fine.

> In my house, I'm dad. In my chorus, I'm Neil. In town I'm Neil
> Cerutti, and in the global scope I have to use a meaningless
> unique identifier. Hopefully no Python namespace ever gets that
> big.

Chorus? Does that imply that you sing? Neat :)

What you have, I think, is a module named Cerutti, in which you have a
class of which Neil is an instance. Inside method functions, you can
be referenced by "self" (which is to code what pronouns are to
English); outside of them, you are referred to as Neil; and outside
the module, Cerutti.Neil is the cleanest way to reference you. But
your name is still Neil, no matter how you're referenced.

Chris Angelico
whose name is sometimes Chris, sometimes Rosuav, and sometimes "Chris
or Michael" by people who can't distinguish him from his brother

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


Thread

is there any principle when writing python function smith jack <thinke365@gmail.com> - 2011-08-23 19:59 +0800
  Re: is there any principle when writing python function Peter Otten <__peter__@web.de> - 2011-08-23 14:20 +0200
    Re: is there any principle when writing python function Roy Smith <roy@panix.com> - 2011-08-23 08:56 -0400
  Re: is there any principle when writing python function Mel <mwilson@the-wire.com> - 2011-08-23 08:53 -0400
  Re: is there any principle when writing python function Roy Smith <roy@panix.com> - 2011-08-23 08:55 -0400
  Re: is there any principle when writing python function Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2011-08-23 15:00 +0200
  Re: is there any principle when writing python function Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-24 01:22 +1000
    Re: is there any principle when writing python function Terry Reedy <tjreedy@udel.edu> - 2011-08-23 14:29 -0400
      Re: is there any principle when writing python function rantingrick <rantingrick@gmail.com> - 2011-08-23 13:22 -0700
      Re: is there any principle when writing python function Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-24 11:44 +1000
  Re: is there any principle when writing python function Seebs <usenet-nospam@seebs.net> - 2011-08-23 16:53 +0000
  Re: is there any principle when writing python function rantingrick <rantingrick@gmail.com> - 2011-08-23 10:02 -0700
    Re: is there any principle when writing python function alex23 <wuwei23@gmail.com> - 2011-08-23 20:05 -0700
    Re: is there any principle when writing python function alex23 <wuwei23@gmail.com> - 2011-08-23 20:08 -0700
      Re: is there any principle when writing python function Red John <redjohn367@gmail.com> - 2011-08-24 16:29 -0700
  Re: is there any principle when writing python function ting@thsu.org - 2011-08-25 22:20 -0700
    Re: is there any principle when writing python function Roy Smith <roy@panix.com> - 2011-08-26 07:15 -0400
      Re: is there any principle when writing python function rantingrick <rantingrick@gmail.com> - 2011-08-26 08:20 -0700
        Re: is there any principle when writing python function John Gordon <gordon@panix.com> - 2011-08-26 15:40 +0000
          Re: is there any principle when writing python function rantingrick <rantingrick@gmail.com> - 2011-08-26 11:05 -0700
            Re: is there any principle when writing python function Chris Angelico <rosuav@gmail.com> - 2011-08-27 07:45 +1000
              Re: is there any principle when writing python function rantingrick <rantingrick@gmail.com> - 2011-08-26 15:26 -0700
              Re: is there any principle when writing python function Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-27 11:26 +1000
                Re: is there any principle when writing python function Chris Angelico <rosuav@gmail.com> - 2011-08-27 11:37 +1000
              Re: is there any principle when writing python function Roy Smith <roy@panix.com> - 2011-08-27 12:41 -0400
                Re: is there any principle when writing python function Chris Angelico <rosuav@gmail.com> - 2011-08-28 02:57 +1000
                Re: is there any principle when writing python function Emile van Sebille <emile@fenx.com> - 2011-08-27 10:27 -0700
                Re: is there any principle when writing python function Ben Finney <ben+python@benfinney.id.au> - 2011-08-28 07:57 +1000
                Re: is there any principle when writing python function Emile van Sebille <emile@fenx.com> - 2011-08-27 15:21 -0700
                Re: is there any principle when writing python function rantingrick <rantingrick@gmail.com> - 2011-08-27 16:01 -0700
                Re: is there any principle when writing python function Roy Smith <roy@panix.com> - 2011-08-27 19:09 -0400
                Re: is there any principle when writing python function Stephen Hansen <me+list/python@ixokai.io> - 2011-08-27 16:27 -0700
                Re: is there any principle when writing python function Chris Angelico <rosuav@gmail.com> - 2011-08-28 03:31 +1000
                Re: is there any principle when writing python function Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-28 06:27 +1000
                Re: is there any principle when writing python function Chris Angelico <rosuav@gmail.com> - 2011-08-28 06:38 +1000
                Re: is there any principle when writing python function Roy Smith <roy@panix.com> - 2011-08-27 17:09 -0400
        Re: is there any principle when writing python function Tobiah <tobiah@teranews.com> - 2011-08-26 08:48 -0700
          Re: is there any principle when writing python function Chris Angelico <rosuav@gmail.com> - 2011-08-27 02:10 +1000
            Re: is there any principle when writing python function Neil Cerutti <neilc@norwich.edu> - 2011-08-29 14:52 +0000
              Re: is there any principle when writing python function Chris Angelico <rosuav@gmail.com> - 2011-08-30 04:20 +1000
                Re: is there any principle when writing python function Neil Cerutti <neilc@norwich.edu> - 2011-08-29 18:40 +0000
                Re: is there any principle when writing python function Chris Angelico <rosuav@gmail.com> - 2011-08-30 05:02 +1000
                For some value of “sing” (was: is there any principle when writing python function) Ben Finney <ben+python@benfinney.id.au> - 2011-08-30 08:17 +1000
                Re: is there any principle when writing python function Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-08-29 23:20 -0700
          Re: is there any principle when writing python function Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-27 04:16 +1000
            Re: is there any principle when writing python function rantingrick <rantingrick@gmail.com> - 2011-08-26 15:37 -0700
  Re: is there any principle when writing python function harrismh777 <harmar@member.fsf.org> - 2011-08-27 23:51 -0500

csiph-web