On 7/9/07, Raymond Hettinger <[EMAIL PROTECTED]> wrote:
> Also, as a practical matter, I think it is a bad idea to introduce
> __getitem__ style access to itertools because the starting point
> moves with each consecutive access:
>
> # access items 0, 2, 5, 9, 14, 20, ...
> for i in range(1
Raymond Hettinger wrote:
> [Walter Dörwald]
>> I'd like to propose the following addition to itertools: A function
>> itertools.getitem() which is basically equivalent to the following
>> python code:
>>
>> _default = object()
>>
>> def getitem(iterable, index, default=_default):
>>try:
>>
[Walter Dörwald]
> I'd like to propose the following addition to itertools: A function
> itertools.getitem() which is basically equivalent to the following
> python code:
>
> _default = object()
>
> def getitem(iterable, index, default=_default):
>try:
> return list(iterable)[index]
>
Guido van Rossum wrote:
> On 7/8/07, Walter Dörwald <[EMAIL PROTECTED]> wrote:
> [quoting Guido]
>> > But I still want to hear of a practical use case for the default here.
>>
>> In most cases
>>
>> foo = getitem(iterable, 0, None)
>> if foo is not None:
>>...
>>
>> is simpler than
Brett Cannon wrote:
> On 7/7/07, Josiah Carlson <[EMAIL PROTECTED]> wrote:
>> Steve Holden <[EMAIL PROTECTED]> wrote:
>>> Tracker wrote:
ACTIVITY SUMMARY (07/01/07 - 07/08/07)
Tracker at http://bugs.python.org/
To view or respond to any of the issues listed b
On 7/8/07, Nick Coghlan <[EMAIL PROTECTED]> wrote:
> Josiah Carlson wrote:
> > "Brett Cannon" <[EMAIL PROTECTED]> wrote:
> >> On 7/5/07, Phillip J. Eby <[EMAIL PROTECTED]> wrote:
> >>> At 11:53 AM 7/5/2007 +0200, Guido van Rossum wrote:
> I see no big problems with this, except I wonder if in
On 7/7/07, Josiah Carlson <[EMAIL PROTECTED]> wrote:
>
> Steve Holden <[EMAIL PROTECTED]> wrote:
> > Tracker wrote:
> > >
> > > ACTIVITY SUMMARY (07/01/07 - 07/08/07)
> > >
> > >
> > > Tracker at http://bugs.python.org/
> > >
> > > To view or respond to any of the issues listed below, sim
At 08:23 PM 7/8/2007 +0300, Paul Pogonyshev wrote:
>I would like to propose an optimization (I think so, anyway) for the
>way attributes are looked up. Currently, it is done like this:
>
> return value of attribute in instance.__dict__ if present
> for type in instance.__class__.__
Hi,
I would like to propose an optimization (I think so, anyway) for the
way attributes are looked up. Currently, it is done like this:
return value of attribute in instance.__dict__ if present
for type in instance.__class__.__mro__:
return value of attribute in type.
On 7/8/07, Kevin Jacobs <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> wrote:
> Also vaguely apropos:
>
> def ilen(seq):
> 'Return the length of the hopefully finite sequence'
> n = 0
> for x in seq:
> n += 1
> return n
Also known as::
sum(1 for _ in iterable)
That's always been simple
On 7/8/07, Guido van Rossum <[EMAIL PROTECTED]> wrote:
Ahem. I hope you have a better use case for getitem() than that
(regardless of the default issue). I find it clearer to write that as
try:
compid = root[ns.company_id].next()
except StopIteration:
compid = None
else:
compid = int(comp
On 7/8/07, Walter Dörwald <[EMAIL PROTECTED]> wrote:
[quoting Guido]
> > But I still want to hear of a practical use case for the default here.
>
> In most cases
>
> foo = getitem(iterable, 0, None)
> if foo is not None:
>...
>
> is simpler than:
>
> try:
>foo = getitem(
Guido van Rossum wrote:
> On 7/8/07, Georg Brandl <[EMAIL PROTECTED]> wrote:
>> Guido van Rossum schrieb:
>>> How important is it to have the default in this API? __getitem__()
>>> doesn't have a default; instead, there's a separate API get() that
>>> provides a default (and I find defaulting to No
On 7/8/07, Georg Brandl <[EMAIL PROTECTED]> wrote:
> Guido van Rossum schrieb:
> > How important is it to have the default in this API? __getitem__()
> > doesn't have a default; instead, there's a separate API get() that
> > provides a default (and I find defaulting to None more manageable than
> >
Guido van Rossum schrieb:
> How important is it to have the default in this API? __getitem__()
> doesn't have a default; instead, there's a separate API get() that
> provides a default (and I find defaulting to None more manageable than
> the "_default = object()" pattern).
getattr() has a default
How important is it to have the default in this API? __getitem__()
doesn't have a default; instead, there's a separate API get() that
provides a default (and I find defaulting to None more manageable than
the "_default = object()" pattern).
--Guido
On 7/8/07, Walter Dörwald <[EMAIL PROTECTED]> wr
> What is my idea, is to make a Python implementation made to be embedded
> into applications..
>
> Hope you have any ideas/comments!
My main question: Who will implement that idea? Ideas are cheap;
making them come true is a lot of work.
It seems that you believe the current implementation of
I'd like to propose the following addition to itertools: A function
itertools.getitem() which is basically equivalent to the following
python code:
_default = object()
def getitem(iterable, index, default=_default):
try:
return list(iterable)[index]
except IndexError:
if d
Josiah Carlson wrote:
> "Brett Cannon" <[EMAIL PROTECTED]> wrote:
>> On 7/5/07, Phillip J. Eby <[EMAIL PROTECTED]> wrote:
>>> At 11:53 AM 7/5/2007 +0200, Guido van Rossum wrote:
I see no big problems with this, except I wonder if in the end it
wouldn't be better to *always* define __packa
19 matches
Mail list logo