From: Zac Medico <zmedico@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Subject: Re: [gentoo-portage-dev] [PATCH] unprivileged mode: generate PORTAGE_DEPCACHEDIR
Date: Mon, 10 Nov 2014 16:17:35 -0800 [thread overview]
Message-ID: <5461559F.2050808@gentoo.org> (raw)
In-Reply-To: <546120FA.9060305@gentoo.org>
On 11/10/2014 12:32 PM, Alexander Berntsen wrote:
> On 10/11/14 19:21, Zac Medico wrote:
>> Well, you'll have to clarify what's so "terrible" about it. Note that I didn't
>> use os.path.isdir or similar because those functions hide all kinds of relevant
>> exceptions, such as EACCES.
> I wish there were a more declarative way of expressing this in Python.
> It's extremely imperative.
We could certainly express it in a way that doesn't involve any mutating
loop control variables, but ultimately that's going to lead to more
lines of code, and it will leave imperative programmers wondering why we
didn't choose a simpler and more succinct approach.
For example, we could create an class for iterating over the paths from
a given path down to the root directory. Then we could create a function
which selects the first element from that iterator that exists. Once the
class and function are implemented, their usage would be very succinct:
first_parent = first_existing(iter_parents(path))
--
Thanks,
Zac
next prev parent reply other threads:[~2014-11-11 0:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-09 23:24 [gentoo-portage-dev] [PATCH] unprivileged mode: generate PORTAGE_DEPCACHEDIR Zac Medico
2014-11-10 4:58 ` [gentoo-portage-dev] " Duncan
2014-11-10 5:28 ` Zac Medico
2014-11-10 6:06 ` Duncan
2014-11-10 11:09 ` [gentoo-portage-dev] " Alexander Berntsen
2014-11-10 18:21 ` Zac Medico
2014-11-10 20:32 ` Alexander Berntsen
2014-11-11 0:17 ` Zac Medico [this message]
2014-11-11 9:14 ` Alexander Berntsen
2014-11-15 5:19 ` Zac Medico
2014-11-15 7:21 ` [gentoo-portage-dev] [PATCH] unprivileged mode: use first_existing helper func Zac Medico
2014-11-17 8:12 ` Alexander Berntsen
2014-11-10 20:48 ` [gentoo-portage-dev] [PATCH v2] unprivileged mode: generate PORTAGE_DEPCACHEDIR Zac Medico
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5461559F.2050808@gentoo.org \
--to=zmedico@gentoo.org \
--cc=gentoo-portage-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox