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


Groups > comp.lang.python > #80393

Re: How do i reduce this to a single function - the code is largely similar, just a direction of search toggle.

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin.stu.neva.ru!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.python
Subject Re: How do i reduce this to a single function - the code is largely similar, just a direction of search toggle.
Date Fri, 7 Nov 2014 15:18:35 +0000 (UTC)
Organization A noiseless patient Spider
Lines 18
Message-ID <m3insb$s06$1@dont-email.me> (permalink)
References <m3i9lp$8fp$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
Injection-Date Fri, 7 Nov 2014 15:18:35 +0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="66ffcfa4470a58bcddbdcd1913f98ab4"; logging-data="28678"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+drHYrdXR47R35gGshEdKrPjJ2qwK8XxQ="
User-Agent Pan/0.136 (I'm far too busy being delicious; GIT 926a150 git://git.gnome.org/pan2)
Cancel-Lock sha1:Dj7We7mjaiP0lMkz9ASJHHwVF+A=
Xref csiph.com comp.lang.python:80393

Show key headers only | View raw


On Fri, 07 Nov 2014 16:46:19 +0630, Veek M wrote:

(1) Pass a true or false parameter to the function as the direction of 
search toggle.

(2) replace the relevant assignments with something like:

variable = something if condition else something else

(3) Figuring out the while loop control is a bit trickier, the best I 
came up with was:

while direction and condition_a or (not direction) and condition_b

But I'm sure someone has something better

-- 
Denis McMahon, denismfmcmahon@gmail.com

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


Thread

How do i reduce this to a single function - the code is largely similar, just a direction of search toggle. Veek M <vek.m1234@gmail.com> - 2014-11-07 16:46 +0630
  Re: How do i reduce this to a single function - the code is largely similar, just a direction of search toggle. Joel Goldstick <joel.goldstick@gmail.com> - 2014-11-07 16:18 -0500
  Re: How do i reduce this to a single function - the code is largely similar, just a direction of search toggle. Denis McMahon <denismfmcmahon@gmail.com> - 2014-11-07 22:22 +0000
  Re: How do i reduce this to a single function - the code is largely similar, just a direction of search toggle. Chris Angelico <rosuav@gmail.com> - 2014-11-08 09:31 +1100
  Re: How do i reduce this to a single function - the code is largely similar, just a direction of search toggle. Veek M <vek.m1234@gmail.com> - 2014-11-07 21:22 +0630
    Re: How do i reduce this to a single function - the code is largely similar, just a direction of search toggle. Ned Batchelder <ned@nedbatchelder.com> - 2014-11-08 07:56 -0500
      Re: How do i reduce this to a single function - the code is largely similar, just a direction of search toggle. Veek M <vek.m1234@gmail.com> - 2014-11-09 15:15 +0630
  Re: How do i reduce this to a single function - the code is largely similar, just a direction of search toggle. Denis McMahon <denismfmcmahon@gmail.com> - 2014-11-07 15:18 +0000

csiph-web