Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

A complex system that works is invariably found to have evolved from a simple system that works.


devel / comp.lang.python / RE: Friday Finking: Contorted loops

SubjectAuthor
* RE: Friday Finking: Contorted loopsAvi Gross
`* Re: Friday Finking: Contorted loopsStefan Ram
 `* RE: Friday Finking: Contorted loopsAvi Gross
  `- Re: Friday Finking: Contorted loopsStefan Ram

1
RE: Friday Finking: Contorted loops

<mailman.706.1631410688.4164.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19536&group=comp.lang.python#19536

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: avigross@verizon.net (Avi Gross)
Newsgroups: comp.lang.python
Subject: RE: Friday Finking: Contorted loops
Date: Sat, 11 Sep 2021 21:38:02 -0400
Lines: 103
Message-ID: <mailman.706.1631410688.4164.python-list@python.org>
References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info>
<she6e0$3bi$1@ciao.gmane.io> <shffd3$p0h$1@ciao.gmane.io>
<YTzAN/9aoKmr9O/P@hjp.at>
<059a01d7a776$d3daa460$7b8fed20$@verizon.net>
Mime-Version: 1.0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de K/bFyspScn8BtfH/u8xvfAZI94xoMAENSvwnJnDcSJ3A==
Return-Path: <avigross@verizon.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=verizon.net header.i=@verizon.net header.b=Pmt4XwA9;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.003
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '(which': 0.04; 'fairly':
0.05; 'searching': 0.05; 'exit': 0.07; 'formal': 0.07; 'loop':
0.07; 'loops.': 0.07; 'modules': 0.07; 'partial': 0.07;
'apparently': 0.09; 'construct': 0.09; 'effectively': 0.09;
'infinite': 0.09; 'occasionally': 0.09; 'solution,': 0.09;
'terry': 0.09; 'then.': 0.09; '"creative': 0.16; "(i'm": 0.16;
'__/': 0.16; 'better?': 0.16; 'challenge!"': 0.16; 'enough,':
0.16; 'examples,': 0.16; 'explaining': 0.16; 'gauld': 0.16;
'happening.': 0.16; 'heavily': 0.16; 'hjp@hjp.at': 0.16; 'holzer':
0.16; 'idea.': 0.16; 'included)': 0.16; 'looping': 0.16; 'loops':
0.16; 'loops,': 0.16; 'reality.': 0.16; 'received:(vzm hermes smtp
server)': 0.16; 'recursion': 0.16; 'redundant': 0.16; 'rewrite':
0.16; 'solved': 0.16; 'stross,': 0.16; 'url-ip:212.17.106.137/32':
0.16; 'url-ip:212.17.106/24': 0.16; 'url-ip:212.17/16': 0.16;
'url:hjp': 0.16; 'vectorized': 0.16; '|_|_)': 0.16; 'wrote:':
0.16; 'problem': 0.16; 'python': 0.16; 'uses': 0.19; 'to:addr
:python-list': 0.20; 'language': 0.21; 'advanced': 0.22; 'code':
0.23; 'lines': 0.23; '(and': 0.25; 'skip:- 10': 0.25; 'python,':
0.25; 'programming': 0.25; '11,': 0.26; 'basics': 0.26; 'suspect':
0.26; 'function': 0.27; 'old': 0.27; 'sense': 0.28; 'this?': 0.29;
'present': 0.30; 'code,': 0.31; 'seem': 0.31; 'approach': 0.31;
'looked': 0.31; 'wondering': 0.31; 'context': 0.32; 'do.': 0.32;
'friday': 0.32; 'guess': 0.32; 'objects': 0.32; 'python-list':
0.32; 'realize': 0.32; 'but': 0.32; "i'll": 0.33; 'there': 0.33;
'someone': 0.34; 'same': 0.34; 'mean': 0.34; 'work.': 0.34;
'header:In-Reply-To:1': 0.34; 'teaching': 0.35; 'cases': 0.36;
'possibly': 0.36; 'people': 0.36; 'change': 0.36; 'those': 0.36;
'special': 0.37; 'using': 0.37; 'though': 0.37; 'could': 0.38;
'quite': 0.39; 'from:': 0.62; 'to:': 0.62; 'seen': 0.62; 'simply':
0.63; 'once': 0.63; 'experience': 0.64; 'personal': 0.64;
'authors': 0.64; 're:': 0.64; 'thus': 0.64; 'your': 0.64; 'plan':
0.64; 'amazing': 0.65; 'similar': 0.65; 'look': 0.65; 'well':
0.65; 'time.': 0.66; 'earlier': 0.67; 'now,': 0.67; 'shows': 0.67;
'back': 0.67; 'mind.': 0.67; 'exactly': 0.68; 'functional': 0.69;
'url-ip:212/8': 0.69; 'older': 0.70; '2021': 0.71; 'direct': 0.73;
'little': 0.73; 'deal': 0.73; 'easy': 0.74; 'tools': 0.74;
'analyze': 0.75; 'ranging': 0.76; 'sent:': 0.78; 'effective':
0.78; 'more.': 0.82; 'reasons': 0.84; 'cleaner': 0.84; 'extent':
0.84; 'horrible': 0.84; 'lesser': 0.84; 'minor': 0.84; 'mood':
0.84; 'pause': 0.84; 'saturday,': 0.84; 'seasoned': 0.84;
'styles': 0.84; 'tiny': 0.84; 'differently': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verizon.net; s=a2048;
t=1631410685; bh=1ugtmxRCLuphh19VnpP8hU33iYlk7F3IvXww2idK3K0=;
h=From:To:References:In-Reply-To:Subject:Date:From:Subject:Reply-To;
b=Pmt4XwA9AJDhpx8vVztWDFgIsw/HrZOFsdHIV2+hQvFTMY+PnPDydncszd0lOiG1UrmOKH8WaH1Y7F5BCv+AW26ufYGd5jlKNxCtTN30oT+trALvoeZ0rjTFY3XIWbcwd0owbeK4Sg4n7bjDrLg7L/n6KaMsXfaX5OazA6/YFjAV3Cfchc6RDfYT04+ShBvBsz6SpYh9Nhnn4niy6cZtcl3/rw02MIaZOW8/UwUA88cGrfvzXpSGy7BWP2tPYZt27zw/Sams1NeoxT+pi/q7+IdT4f+FYxvsK+MA+MJwtH/L6QQZ6JDQugVRduEZPJ7B5TkhG4UoHs7IJimpbprmfA==
X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048;
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zR8LQvytgnpbghJv85e5ZWCeFEVh0AAiH5UnvprjqrWIf9H1MXxKoONIGT7yc3uc
i2CywCINffe3dt17y9WryZ55UpsHchX7Wnp4RrFffj8CJlIvHeu7QrDg087eLoPM._aKWewGDXZz
EwAHgroh2ZziBX4F6NsTQ0qhDsgAzGY8C0HBDmNnR_mUQkdV8MwL88jOBj1EScz4awfG6ToNPNl0
MZmx_BsUNQdRrUn7GtnN7kkTmznBCQIGwCprjTPdqFc0.rT0PzO6HS2eY5pAsM._KVx0iJZL._K_
YihpV7CS0zNjCd40qUBAK6AFf3ThVY6KtjCGe3uvweUo9Fp46noGZvPIHfL72QiWsaDf4BpNc34D
nX3HGv11CJU8kP7_xj38SFNg6jQkpQOTONhHVqzsaV6VH2qXaAE4YEBxNvdDJ7Mu7qKMam_0Gs4x
MeJirOBmUmnPgkb.xHoP36dVXAf5HW0kFQzoM8EoY6Pw_p7TXggwax0gDmwZGIZ2AnMVk5Tg.gGY
PLpemTQ0jh1Vr685FZb1YE5wwrKmJiIyngkXNcq8iJ3ZapHnbc9aFRv5FH40ZS.EJKjSlmneT4Qi
MhvXp2JN3540GBpjxYPmCgCfPFv_EAvXvrtgUrGWcR0ASb2fTnjw5TmbWpOKxIZPDbw--
X-Sonic-MF: <avigross@verizon.net>
In-Reply-To: <YTzAN/9aoKmr9O/P@hjp.at>
X-Mailer: Microsoft Outlook 16.0
Content-Language: en-us
Thread-Index: AQH8RFnQrsJfLkU50XE9+Q5aLLwBIgI1rsnrAPdcHy0COQJ+rqsqyyuw
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
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: <https://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>
X-Mailman-Original-Message-ID: <059a01d7a776$d3daa460$7b8fed20$@verizon.net>
X-Mailman-Original-References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info>
<she6e0$3bi$1@ciao.gmane.io> <shffd3$p0h$1@ciao.gmane.io>
<YTzAN/9aoKmr9O/P@hjp.at>
 by: Avi Gross - Sun, 12 Sep 2021 01:38 UTC

Peter, in your own personal finite sample, I am wondering what you might do
TODAY if you looked at your loops again and considered redoing them for an
assortment of reasons ranging from using the code for teaching to efficiency
to just fitting your mood better?

I have seen seasoned authors go back to their early work and groan. Some
have even reissued earlier work with a partial rewrite often with a long
additional preface explaining why and even mentioned what was changed and
bemoaning how they thought differently back then.

My guess is that many of us (meaning myself included) often approach a
problem and go with the first thing that comes to mind. If it fits well
enough, we move on to the next thing we can do. If not, we may step back and
evaluate multiple additional options and try another tack.

I have seen not of sort-of redundant code because someone did not plan ahead
and realize something very similar might be needed later and thus did not
make a general function they could re-use. Occasionally they may later go
back and re-do but often, not so much and just keep copying lines and making
minor modifications. Same general idea.

And perhaps worse, you may write a loop and later have to keep adding code
to deal with new requirements and special cases and rather than pause and
analyze and perhaps start again with a cleaner or more easily extendable
solution, just keep grafting on things to make the darn current code work.
Code that has many ways to exit a loop is often an example of this
happening.

So if you looked at your own code now, in the context of the rest of your
code, would you change things?

in python, I suspect I would seriously change an amazing number of things
for older code including code being ported. It supports quite a few
programming constructs and styles and has access to plenty of modules that
mean you need not re-invent all the time. How many formal loops might you
replace with a list comprehension or use a generator, NOW? How many problems
you once solved by doing things like looping and searching for an element
being present in a list when now you might use a set or dictionary?

The reality is many people learn the basics of a language and write using
fairly basic constructs and only later master the more advanced topics. But
their mature work may then often heavily use those later and more effective
methods. Functional programming often uses constructs where loops become
invisible. Objects often hide loops in all kinds of methods. Sometimes
recursion effectively does a loop. It is sometimes easy to write programs
with no visible loops.

So when counting the various kinds, are you looking for direct or indirect
methods too like map/reduce or vectorized operations?

-----Original Message-----
From: Python-list <python-list-bounces+avigross=verizon.net@python.org> On
Behalf Of Peter J. Holzer
Sent: Saturday, September 11, 2021 10:42 AM
To: python-list@python.org
Subject: Re: Friday Finking: Contorted loops

On 2021-09-10 12:26:24 +0100, Alan Gauld via Python-list wrote:
> On 10/09/2021 00:47, Terry Reedy wrote:
> > even one loop is guaranteed.) "do-while" or "repeat-until is even
> > rarer since fractional-loop include this as a special case.
>
> Is there any empirical evidence to support this?
> Or is it just a case of using the tools that are available?
> In my experience of using Pascal (and much later with Delphi) that I
> used repeat loops at least as often as while loops, possibly more.
>
> But using Python and to a lesser extent C (which has a rather horrible
> do/while) construct

How is C's do/while loop more horrible than Pascal's repeat/until? They seem
almost exactly the same to me (the differences I see are the inverted
condition (debatable which is better) and the added block delimiters (which
I actually like)).

> So is it the case that the "need" for repeat loops is rare, simply a
> result of there being no native repeat loop available?

A tiny non-representative data point:

In an old collection of small C programs of mine I find:

35 regular for loops
28 while loops
2 infinite for loops
1 "infinite" for loop (i.e. it exits somewhere in the middle)
0 do/while loops.

So even though do/while loops are available in C (and I don't find them
horrible) I apparently found very little use for them (I'm sure if I look
through more of my C programs I'll find a few examples, but this small
samples shows they are rare.

hp

--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"

Re: Friday Finking: Contorted loops

<repetitions-20210912035323@ram.dialup.fu-berlin.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19537&group=comp.lang.python#19537

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Friday Finking: Contorted loops
Date: 12 Sep 2021 02:55:40 GMT
Organization: Stefan Ram
Lines: 35
Expires: 1 Dec 2021 11:59:58 GMT
Message-ID: <repetitions-20210912035323@ram.dialup.fu-berlin.de>
References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info> <she6e0$3bi$1@ciao.gmane.io> <shffd3$p0h$1@ciao.gmane.io> <YTzAN/9aoKmr9O/P@hjp.at> <059a01d7a776$d3daa460$7b8fed20$@verizon.net> <mailman.706.1631410688.4164.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de m49dlNDR0nDrYiyarJ1dPACATV8neVXhMRSRj74stTwik6
X-Copyright: (C) Copyright 2021 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Sun, 12 Sep 2021 02:55 UTC

"Avi Gross" <avigross@verizon.net> writes:
>I have seen not of sort-of redundant code because someone did not plan ahead

From my experience, the "plan ahead" approach (waterfall model)
often is less applicable than the "code is design" (Reeve) +
"refactoring" (Fowler) approach. (However, in some fields, planning
ahead is a requirement).

>and realize something very similar might be needed later and thus did not
>make a general function they could re-use. Occasionally they may later go
>back and re-do but often, not so much and just keep copying lines and making
>minor modifications. Same general idea.

I remember having read a discussion in the Web.
The question was something like:

How many times do you have to write a piece of code,
before you create a function for it?

I believe I still remember two answers:

- One time.

- Three times.

The justification I can't remember, but what I would come up
with now would be:

(for "one time":) Functions structure your code. You don't have
to wait for repetitions as an "excuse" to create them.

(for "three times:) Relax. Don't overengineer. You need to have
at least /three/ repetitions to be able to see a clear pattern.

RE: Friday Finking: Contorted loops

<mailman.713.1631475116.4164.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19550&group=comp.lang.python#19550

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: avigross@verizon.net (Avi Gross)
Newsgroups: comp.lang.python
Subject: RE: Friday Finking: Contorted loops
Date: Sun, 12 Sep 2021 15:31:48 -0400
Lines: 99
Message-ID: <mailman.713.1631475116.4164.python-list@python.org>
References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info>
<she6e0$3bi$1@ciao.gmane.io> <shffd3$p0h$1@ciao.gmane.io>
<YTzAN/9aoKmr9O/P@hjp.at> <059a01d7a776$d3daa460$7b8fed20$@verizon.net>
<mailman.706.1631410688.4164.python-list@python.org>
<repetitions-20210912035323@ram.dialup.fu-berlin.de>
<00b501d7a80c$d43de8e0$7cb9baa0$@verizon.net>
Mime-Version: 1.0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de khYpTKI7ZRGrRyncFt5KjQu+QZ2p22fzChjzTfV4wf6g==
Return-Path: <avigross@verizon.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=verizon.net header.i=@verizon.net header.b=qCgxo8qp;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.007
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'comments': 0.03; '(for':
0.05; 'away.': 0.05; 'bigger': 0.05; 'fairly': 0.05; 'is.': 0.05;
'ram': 0.07; 'bothering': 0.09; 'graph': 0.09; 'moved': 0.09;
'occasionally': 0.09; 'overhead': 0.09; 'tons': 0.09; 'trivial':
0.09; 'web.': 0.09; 'writes:': 0.09; 'url:mailman': 0.15;
'approach.': 0.16; 'arguments': 0.16; 'column': 0.16;
'consolidated': 0.16; 'dotted': 0.16; 'explaining': 0.16;
'feature.': 0.16; 'gig': 0.16; 'graphs': 0.16; 'idea.': 0.16;
'loops': 0.16; 'mathematical': 0.16; 'on!': 0.16; 'pdf.': 0.16;
'received:(vzm hermes smtp server)': 0.16; 'redundant': 0.16;
'remember,': 0.16; 'repeated': 0.16; 'rewrite': 0.16; 'spending':
0.16; 'top-down': 0.16; 'unit,': 0.16; 'wider': 0.16; 'problem':
0.16; 'code.': 0.17; 'instead': 0.17; "can't": 0.17; 'uses': 0.19;
'it?': 0.19; 'to:addr:python-list': 0.20; 'written': 0.22;
'languages': 0.22; 'code': 0.23; 'lines': 0.23; 'idea': 0.24;
'skip:- 10': 0.25; 'url-ip:188.166.95.178/32': 0.25; 'url-
ip:188.166.95/24': 0.25; 'discussion': 0.25; 'url:listinfo': 0.25;
'url-ip:188.166/16': 0.25; 'anyone': 0.25; '11,': 0.26; 'stefan':
0.26; 'else': 0.27; 'coming': 0.27; 'function': 0.27; 'done':
0.28; 'background': 0.28; 'output': 0.28; 'series': 0.28;
'printed': 0.28; 'requests': 0.28; 'environment': 0.29; 'code,':
0.31; 'seem': 0.31; 'approach': 0.31; 'url-ip:188/8': 0.31;
'think': 0.32; 'question': 0.32; 'friday': 0.32; 'python-list':
0.32; 'realize': 0.32; 'structure': 0.32; 'unless': 0.32; 'but':
0.32; 'there': 0.33; 'someone': 0.34; 'able': 0.34; 'same': 0.34;
'header:In-Reply-To:1': 0.34; 'fine': 0.35; 'functions': 0.36;
'guide': 0.37; 'using': 0.37; 'others': 0.37; 'could': 0.38;
'means': 0.38; 'read': 0.38; 'two': 0.39; 'remember': 0.61;
'skip:o 10': 0.61; 'above': 0.62; 'from:': 0.62; 'to:': 0.62;
'color': 0.62; 'seen': 0.62; 'point.': 0.62; 'reasonable': 0.62;
'showing': 0.62; 'come': 0.62; 'clear': 0.64; 'full': 0.64; 're:':
0.64; 'thus': 0.64; 'times.': 0.64; 'your': 0.64; 'plan': 0.64;
'amazing': 0.65; 'applicable': 0.65; 'similar': 0.65; 'well':
0.65; 'less': 0.65; 'improve': 0.66; 'time.': 0.66; 'back': 0.67;
'right': 0.68; 'interested': 0.68; 'and,': 0.69; 'piece': 0.69;
'stock': 0.69; 'analysis': 0.69; 'times': 0.69; 'too.': 0.70;
'2021': 0.71; 'longer': 0.71; 'little': 0.73; 'late': 0.73;
'zone': 0.76; 'sent:': 0.78; 'delivered': 0.84; 'danger': 0.84;
'decent': 0.84; 'dozen': 0.84; 'gray': 0.84; 'luck': 0.84;
'minor': 0.84; 'saturday,': 0.84; 'behind': 0.88; 'badly': 0.91;
'received:74.6.132': 0.91; 'line,': 0.93; 'agreed': 0.95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verizon.net; s=a2048;
t=1631475113; bh=LtLyglPDQ6zJJ/rExKhKC+ZrdCUS9j8LcgSvP6SFT2g=;
h=From:To:References:In-Reply-To:Subject:Date:From:Subject:Reply-To;
b=qCgxo8qpm4zYrMegkrEki531ui7LSI7ZRvkVt5xtDPN+SHo4gsJ0rqQ4iHxH74eZV4/kZ/1pFZl8yKkyeVWNzTSS+ftz6LU7wDFbG1+DU76IH4nHnq7gECj+fEk4yl2nQGobWj5A7XrI8+IeMRdUmPhbVPSNGCxyJGKo5QmDm3vVP0ppwjQqMBusLbv7SRamfoI0JO/SqysFOgl/8X2Q3SWmvKFF83tSG/0VeEwdq2bWabeuYyEHeS7pr1E8VWcrzsistRgbuVxEIj9Up4xZoQTWVkjWdmgfP8t5cz2/UzJuwALkG97SkaF/HokP8I5Xo1tKna/AjlOHNM0hyo4Whg==
X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048;
t=1631475113; bh=6pJxP88A37IpxzeAeugoZEMthVB15gD6TzZ2swLM8pd=;
h=X-Sonic-MF:From:To:Subject:Date:From:Subject;
b=ZZ/0xcF+Yc/DTmbxHApxwStwXnrd7BhKv3c35iEDiuXPS2FMMtCGQ4KibHITFp7UJKqhPnhHMpmE33KF4ctyyC2jjOfVg7I/L/esC3KXCAhZQMgYCQcCAMSO5mXxuCOy1bZrqJdRAg2gzB0P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4e7MBnYFbdeW6tqSHhQAdsyy0oZdpif8_4cfXl9piap289.oajqBlxMNvchS4Hnv6AaQ3qc
KygDGp0rs5iM0Yqtdz0SJBP9sPBtaNo3y9vrMpeMzg2jDwJVHoDYRvkMiRojx1OZ4VHj2pF7tM87
rnOyRkC6U6Jhv5BcfPa7QeWjnvEtBNM2XCkC5cWSx6JBeA87IwDSPvPbeR8JL6mOiha9cvRVWdO_
tYXawPk1HeRm7DU_N_5fFBW17xsiD5UF.d_KY.sXo8hXOULi6yk9T1z0p7vcgou1Rm7VCtbkpkKQ
TZjz4MjCBTHMOjuDiAaZi.duVv451rjvcbz7gLrlmGay49kEM08A9W6TcRefzEU_FI1RIGFl_nag
aRvdvafEl_O0rQt69UaMPWuhpbGaMsFj_1_sO2jzp1dgx.Fh5vE5rq3940rgG2OY-
X-Sonic-MF: <avigross@verizon.net>
In-Reply-To: <repetitions-20210912035323@ram.dialup.fu-berlin.de>
X-Mailer: Microsoft Outlook 16.0
Content-Language: en-us
Thread-Index: AQH8RFnQrsJfLkU50XE9+Q5aLLwBIgI1rsnrAPdcHy0COQJ+rgK+Xb5rAjhwX8MBgkpW/6r4ko8g
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
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: <https://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>
X-Mailman-Original-Message-ID: <00b501d7a80c$d43de8e0$7cb9baa0$@verizon.net>
X-Mailman-Original-References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info>
<she6e0$3bi$1@ciao.gmane.io> <shffd3$p0h$1@ciao.gmane.io>
<YTzAN/9aoKmr9O/P@hjp.at> <059a01d7a776$d3daa460$7b8fed20$@verizon.net>
<mailman.706.1631410688.4164.python-list@python.org>
<repetitions-20210912035323@ram.dialup.fu-berlin.de>
 by: Avi Gross - Sun, 12 Sep 2021 19:31 UTC

Stefan,

Agreed that writing code to handle all possible eventualities is usually
overkill and results in bloated software delivered very late or not at all.

My point is that often OTHERS start adding requests afterward that seem
trivial to THEM as they have no idea what it takes. I have often done some
kind of data analysis for someone and made a few graphs and suddenly they
ask if I can add something else to the graph such as a few horizontal lines
showing where a danger zone lies, or some kind of average. No problem but to
do that means the new info has to have been made available or can be
calculated and often even means my function needs to take more arguments or
a wider data.frame. Then they reconsider and ask if instead of a line, can I
color the background above that point. Well, yeah, but now I might need to
calculate another column to use to guide that feature. Ah, but can you show
a series of related such graphs as a unit, or perhaps combine several
unrelated graphs in a 3 by 2 matrix. Argh! Sure, I can do that but you did
not ask me to before I started. I now might toss out much of my original
code and rewrite something so all the things needed are made first and then
the graphs are made and recombined in the right output format. This means
that what used to make a graph will now make a data structure to return that
can be used later to recombine into a bigger consolidated graphic.

Does the story end here? Nope. Tons more requests like removing color and
using shades of gray or dotted lines so it can be printed on any printer,
changing the point size of text and other characteristics and introduce
mathematical symbols and equations along the axes and I swear an amazing
number of such fine tunings including taking a series of these things into
one multi-page PDF.

If this was a paid gig and someone offered me a fixed sum, should I tolerate
almost any changes? If this was a regular paid job and this made me late and
not get other things done?

My bottom line is that it may not be reasonable to make a detailed top-down
design and stock with it BUT that code written by ever-changing requirements
can end up badly too. I shudder at times I wrote decent code full of
comments explaining well and a while later had a mess where the comments
lagged behind changes in the code as there was no point in bothering to
update them unless it stopped changing. And, often, by then, I was no longer
interested in spending any more time and sometimes just removed all the
comments and moved on! Good luck to anyone coming along to maintain or
improve the code.

I have to think about when to make a function. Something trivial is often
not worth is. And making a very abstract function that can do a dozen things
if invoked just right with many arguments is sometimes a tad too much when a
few simpler functions might do as well with less overhead and especially
when the uses have fairly little in common. Some languages may discourage
you if the repeated code needs to do things in the current environment and
thus only part of the functionality can be moved away.

-----Original Message-----
From: Python-list <python-list-bounces+avigross=verizon.net@python.org> On
Behalf Of Stefan Ram
Sent: Saturday, September 11, 2021 10:56 PM
To: python-list@python.org
Subject: Re: Friday Finking: Contorted loops

"Avi Gross" <avigross@verizon.net> writes:
>I have seen not of sort-of redundant code because someone did not plan
>ahead

From my experience, the "plan ahead" approach (waterfall model)
often is less applicable than the "code is design" (Reeve) +
"refactoring" (Fowler) approach. (However, in some fields, planning
ahead is a requirement).

>and realize something very similar might be needed later and thus did
>not make a general function they could re-use. Occasionally they may
>later go back and re-do but often, not so much and just keep copying
>lines and making minor modifications. Same general idea.

I remember having read a discussion in the Web.
The question was something like:

How many times do you have to write a piece of code,
before you create a function for it?

I believe I still remember two answers:

- One time.

- Three times.

The justification I can't remember, but what I would come up
with now would be:

(for "one time":) Functions structure your code. You don't have
to wait for repetitions as an "excuse" to create them.

(for "three times:) Relax. Don't overengineer. You need to have
at least /three/ repetitions to be able to see a clear pattern.

--
https://mail.python.org/mailman/listinfo/python-list

Re: Friday Finking: Contorted loops

<contracts-20210912205749@ram.dialup.fu-berlin.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19551&group=comp.lang.python#19551

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Friday Finking: Contorted loops
Date: 12 Sep 2021 19:59:22 GMT
Organization: Stefan Ram
Lines: 38
Expires: 1 Dec 2021 11:59:58 GMT
Message-ID: <contracts-20210912205749@ram.dialup.fu-berlin.de>
References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info> <she6e0$3bi$1@ciao.gmane.io> <shffd3$p0h$1@ciao.gmane.io> <YTzAN/9aoKmr9O/P@hjp.at> <059a01d7a776$d3daa460$7b8fed20$@verizon.net> <mailman.706.1631410688.4164.python-list@python.org> <repetitions-20210912035323@ram.dialup.fu-berlin.de> <00b501d7a80c$d43de8e0$7cb9baa0$@verizon.net> <mailman.713.1631475116.4164.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de TWHaquZQjpflLrGh5glltQiuUoWWbzYf+BVkVgokiZoLSu
X-Copyright: (C) Copyright 2021 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Sun, 12 Sep 2021 19:59 UTC

"Avi Gross" <avigross@verizon.net> writes:
>If this was a paid gig and someone offered me a fixed sum, should I tolerate
>almost any changes? If this was a regular paid job and this made me late and
>not get other things done?

A question is raised here which leaves the technology of
software creation and reaches into the area of software
contract design and software contract implementation.

In the Federal Republic of Germany, an employee is a
dependent worker who is bound by the instructions of his
employer. If that employer instructs the employee that
activity A should have priority over activity B, then it is
not the employee's problem to worry about the consequences.

Here now follow remark concerning freely negotiated
contracts for software projects:

From the point of view of contract drafting, you can make a
preliminary contract that regulates the creation of
a specification. If the specification is accepted by the
client, the main contract comes into force and the
specification is realized. Requests for changes would
require new contract negotiations, during which such
requests can be rejected.

When implementing the contract, it can be difficult for the
contractor to always say "no" to change requests if he is
working from a weaker position (for example, if he urgently
needs that customer or money).

Alternatively, an "agile" contract can be designed that
"embraces" change requests, although here the contract
design can be a bit trickier. Surely the customer will have
to pay more one way or another if they want more changes /
enhancements here too.


devel / comp.lang.python / RE: Friday Finking: Contorted loops

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor