Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #74829
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@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; 'value,': 0.04; 'string.': 0.05; 'already.': 0.09; 'alter': 0.09; 'function,': 0.09; 'lawrence': 0.09; 'mind,': 0.09; 'pep': 0.09; 'subject:string': 0.09; 'python': 0.11; 'def': 0.12; 'suggest': 0.14; "wouldn't": 0.14; 'agree.': 0.16; 'end))': 0.16; 'formatted': 0.16; 'naming': 0.16; 'optional': 0.16; 'subject:library': 0.16; 'url:pep-0008': 0.16; 'url:peps': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'first.': 0.19; 'url:dev': 0.24; "haven't": 0.24; 'second': 0.26; 'header :In-Reply-To:1': 0.27; 'function': 0.29; 'skip:p 30': 0.29; 'besides': 0.30; 'message-id:@mail.gmail.com': 0.30; 'usually': 0.31; 'flags': 0.31; 'url:python': 0.33; 'style': 0.33; 'third': 0.33; 'subject:the': 0.34; 'received:google.com': 0.35; 'really': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'should': 0.36; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'changed': 0.39; 'skip:p 20': 0.39; 'read': 0.60; 'completed': 0.61; 'book,': 0.68; 'line,': 0.68; 'default': 0.69; 'jul': 0.74; 'behavior': 0.77; 'functions:': 0.84; 'horrible': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=Hi8KFrEX7yUlgpAx3mZk8UmiaPe87TI6Qa/V+tSgjEs=; b=AHMBvWj7iHcdXBKqjuBrEkpiVVMxLN8AfYZdkuexv7hxcusGRpauXA/Uu7iH45Mxx0 WEuA9lv87MmJg5+HbAVl75pQenCKOh56LlYByW8lPORfizuNTRHO93euGvp5sVzEVekz JEcv4Ib0w96MQc9K8EaYEvxSgzt2p32hhQd3vpluo7dwsBBVuPe+z9MuKuPpvXg8CPNb 198HdwrlbpzVX9y0dlo/3C384ym9bw0t2BPrJnqAVER8UMpPGvJpncj4PQbJL/eDZvt+ 8BNVx8+2Icdq0jBSISVPIYR1VsMFfKVM5tRA8OUhW54mW9fZpVX8aPCScwm2qkr8OWBi pcEg== |
| X-Received | by 10.66.231.40 with SMTP id td8mr13709591pac.107.1405796255977; Sat, 19 Jul 2014 11:57:35 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <lqed60$si$1@ger.gmane.org> |
| References | <53CAAD27.9010207@cdreimer.com> <lqed60$si$1@ger.gmane.org> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Sat, 19 Jul 2014 12:56:55 -0600 |
| Subject | Re: What's the proper style for a library string function? |
| To | Python <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.12057.1405796265.18130.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1405796265 news.xs4all.nl 2966 [2001:888:2000:d::a6]:33868 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:74829 |
Show key headers only | View raw
On Sat, Jul 19, 2014 at 12:24 PM, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote:
> Besides that I wouldn't write the function on one line, the first. Once you
> return your data you can do what you want with it. The second you can only
> write by default to stdout. The third is really horrible in my book, YMMV.
I agree. Optional flags that alter the behavior of functions are
considered unpythonic; usually it's better to let the alternative
behavior have its own function, particularly if they can share
implementation.
With that in mind, I would suggest to the OP that you might want to
have *two* functions:
def format_completed_time(start, end):
return "Time completed: " + str(end - start)
def print_completed_time(start, end):
print(get_completed_time(start, end))
Also notice that I changed the function naming style from mixedCase to
lower_case_with_underscores. This is the style recommended for Python
by PEP 8, which you should read if you haven't already.
http://legacy.python.org/dev/peps/pep-0008/#naming-conventions
I also changed the verb from "get" to "format". "get" suggests to me
that it will retrieve the completed time as a processable value, not
as a part of a formatted string.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: What's the proper style for a library string function? Ian Kelly <ian.g.kelly@gmail.com> - 2014-07-19 12:56 -0600
csiph-web