Why does argparse return None instead of  if an append action isn't used?
ian.g.kelly at gmail.com
Mon Jan 26 17:13:38 CET 2015
On Mon, Jan 26, 2015 at 8:50 AM, Adam Funk <a24061 at ducksburg.com> wrote:
> On 2015-01-26, Peter Otten wrote:
>> Adam Funk wrote:
>>> On 2015-01-09, Ned Batchelder wrote:
>>>> for b in options.bar or ():
>>> Do you mean "for b in options.bar or :" ?
>> Doesn't matter; in the context of a for loop any empty iterable would do.
> Of course it would. Doh!
Stylistically, I generally prefer the empty list for this. The empty
tuple might be a little faster since it's a singleton and doesn't need
to be constructed at runtime, but that's clearly a micro-optimization,
and I think the list more accurately conveys the intention of
"something to be iterated over". Although tuples are iterable, I don't
often use them for that purpose.
More information about the Python-list