[issue25215] Simple extension to iter(): iter() returns empty generator

2015-09-22 Thread Brett Cannon

Brett Cannon added the comment:

I agree with Raymond. Allowing a non-argument iter() runs the risk of someone 
messing up and forgetting the arguments and yet having no error that they did 
so. And considering how easy it is to get an iterator of an empty list or tuple 
I don't see a benefit.

Thanks for the suggestion, Jurjen, but I'm closing this as rejected.

--
nosy: +brett.cannon
resolution:  -> rejected
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25215] Simple extension to iter(): iter() returns empty generator

2015-09-22 Thread Jurjen N.E. Bos

New submission from Jurjen N.E. Bos:

When looking for a "neat" way to create an empty generator, I saw on 
stackOverflow that the crowd wasn't sure what was the "least ugly" way to do it.
Proposals where:
def emptyIter(): return; yield
or
def emptyIter(): return iter([])

Then it struck me that a trivial extension to the iter() built-in would be to 
allow to call it without arguments, thus giving a simple to understand empty 
iterator, and allowing:
def emptyIter(): return iter()
(And, of course, this function would not need to exist in any reasonable 
program in that case.)

The implementation would be trivial, I assume.

--
components: Library (Lib)
messages: 251324
nosy: jneb
priority: normal
severity: normal
status: open
title: Simple extension to iter(): iter() returns empty generator
type: enhancement
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25215] Simple extension to iter(): iter() returns empty generator

2015-09-22 Thread Zachary Ware

Changes by Zachary Ware :


--
versions:  -Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25215] Simple extension to iter(): iter() returns empty generator

2015-09-22 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I'm not sure that python needs a neater way to make an empty generator.  It 
isn't a common use case and there isn't anything wrong with iter([]).

There are downsides to expanding an API.  It creates yet another thing to learn 
and remember.  Even now, few developers know about the two-argument form of 
iter().

--
assignee:  -> rhettinger
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com