All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Frans Klaver" <fransklaver@gmail.com>
Cc: "Michael Haggerty" <mhagger@alum.mit.edu>,
	"Karl Hasselström" <kha@treskal.com>,
	"Catalin Marinas" <catalin.marinas@gmail.com>,
	"Andy Green (林安廸)" <andy@warmcat.com>,
	git@vger.kernel.org
Subject: Re: [StGit PATCH] Parse commit object header correctly
Date: Wed, 08 Feb 2012 19:58:54 -0800	[thread overview]
Message-ID: <7v39akzmgx.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <op.v9dl1e0v0aolir@keputer.lokaal> (Frans Klaver's message of "Wed, 08 Feb 2012 21:04:16 +0100")

"Frans Klaver" <fransklaver@gmail.com> writes:

>>>>           for line in lines:
>>>>               try:
>>>>                   key, value = line.rstrip('\n').split(' ', 1)
>>>>               except ValueError:
>>>>                   continue
>>>
>>> This is generally considered more pythonic: "It's easier to ask for
>>> forgiveness than to get permission".
>>
>> Given that Junio explicitly wanted to allow lines with no spaces, I
>> assume that lack of a space is not an error but rather a conceivable
>> future extension.  If my assumption is correct, then it is misleading
>> (and inefficient) to handle it via an exception.
>
> I find the documenting more convincing than the efficiency, but from
> the phrasing I think you do too.

A line that consists entirely of non-SP may or may not a conceivable
future extension, but the point is to "skip without barfing anything you
do not understand".

I wouldn't oppose the rewrite that uses try/except ValueError if
"everything in this try block will parse what I understand correctly, and
any ValueError exception this try block throws is an indication that I
encountered what I do not understand and I must skip" is the more pythonic
way to express that principle. Python is not my primary language as I
said, and in addition StGit may have its own style I haven't learned.

  reply	other threads:[~2012-02-09  3:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-07 13:02 STGIT: Deathpatch in linus tree "Andy Green (林安廸)"
2012-02-07 17:37 ` Junio C Hamano
2012-02-08  7:33   ` [StGit PATCH] Parse commit object header correctly Junio C Hamano
2012-02-08 10:00     ` Michael Haggerty
2012-02-08 10:43       ` Frans Klaver
2012-02-08 16:17         ` Michael Haggerty
2012-02-08 20:04           ` Frans Klaver
2012-02-09  3:58             ` Junio C Hamano [this message]
2012-02-15 12:24       ` Catalin Marinas
2012-02-15 18:13         ` Junio C Hamano
2012-02-15 18:40         ` "Andy Green (林安廸)"
2012-02-09  9:38     ` Catalin Marinas
2012-02-09 17:51       ` Jonathan Nieder
2012-02-10  4:27         ` Nguyen Thai Ngoc Duy
2012-02-09 19:04       ` Junio C Hamano

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=7v39akzmgx.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=andy@warmcat.com \
    --cc=catalin.marinas@gmail.com \
    --cc=fransklaver@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=kha@treskal.com \
    --cc=mhagger@alum.mit.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.