public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download: 
* Re: [gentoo-portage-dev] equery: RFC and code review
  @ 2009-02-12 11:27 99%   ` Marijn Schouten (hkBst)
  0 siblings, 0 replies; 1+ results
From: Marijn Schouten (hkBst) @ 2009-02-12 11:27 UTC (permalink / raw
  To: gentoo-portage-dev

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Alec Warner wrote:
> On Tue, Feb 10, 2009 at 2:53 AM, Douglas Anderson <dja@gendja.com> wrote:
<snip>
> belongs.py has this gem:
> q.append(('^' if query[0] == '/' else '/') + re.escape(query) + '$')
> 
> I realize it works; but honestly, not readable.
> 
> append_str = ""
> if query[0] == '/' append_str += '^' else append_str += '/'
> append_str += re.escape(query) + '$'
> q.append(append_str)
> 
> Slightly better (if append_str has a shorter name, maybe).  I don't
> like 1 line if EXPR STATEMENT else STATEMENT but sometimes they are
> shorter
> Putting a conditional in the function call is horrible looking though.

It's called functional programming. Maybe it takes a little getting used to, but
as your own example shows, it can cut your code base by a significant factor.

Marijn


- --
Sarcasm puts the iron in irony, cynicism the steel.

Marijn Schouten (hkBst), Gentoo Lisp project, Gentoo ML
<http://www.gentoo.org/proj/en/lisp/>, #gentoo-{lisp,ml} on FreeNode
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkmUB54ACgkQp/VmCx0OL2wIOQCfdd0U1TJ/GXxTwvV8vmMpW2u9
hfsAoIXkWvJP8sOGK4NstuXiCAgy5OIf
=qfq4
-----END PGP SIGNATURE-----



^ permalink raw reply	[relevance 99%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2009-02-10 10:53     [gentoo-portage-dev] equery: RFC and code review Douglas Anderson
2009-02-12  7:10     ` Alec Warner
2009-02-12 11:27 99%   ` Marijn Schouten (hkBst)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox