?

castironpi castironpi at gmail.com
Thu May 15 22:26:39 EDT 2008


On May 15, 6:52 pm, afrobeard <afrobe... at gmail.com> wrote:
> l.__delslice__(0,len(l)) is an expression as it returns None which is
> a value
>
> On May 16, 4:23 am, castironpi <castiro... at gmail.com> wrote:
>
>
>
> > On May 15, 6:07 pm, afrobeard <afrobe... at gmail.com> wrote:
>
> > > The following proposed solution is not intended to be a solution, it
> > > goes completely against the zen of python. [Type import this into the
> > > python command interpreter]
>
> > > I brought it down to two lines:-
>
> > > l = range(6)
> > > [1 if b!=4 else l.__delslice__(0,len(l)) for b in l][:-1]
>
> > > itertools would still be a better approach in my opinion.
>
> > > Just because I'm curious to know, can anyone bring it shorter[even if
> > > its cryptic] than this without invoking any Python Library.
>
> > > P.S. Once again I would not recommend using this as Explicit is better
> > > than Implicit
> > > P.P.S. It is strongly undesirable for us humans to use anything
> > > starting with __ :)
>
> > > On May 15, 5:10 pm, "Geoffrey Clements"
>
> > > <geoffrey.clement... at SPAMbaesystems.com> wrote:
> > > > "urikaluzhny" <ukaluz... at nds.com> wrote in message
>
> > > >news:51e0f25d-474a-450a-ad00-92f70c893c6c at m44g2000hsc.googlegroups.com...
> > > > On May 15, 10:06 am, "Terry Reedy" <tjre... at udel.edu> wrote:
>
> > > > > "urikaluzhny" <ukaluz... at nds.com> wrote in message
>
> > > > >news:f8229614-a000-450e-85eb-825e6c1386cf at w7g2000hsa.googlegroups.com...
> > > > > | It seems that I rather frequently need a list or iterator of the form
> > > > > | [x for x in <> while <>]
>
> > > > > I can think of two ways to interpret that.
> > > > >> I mean like [x for x in <A> if <B>], only that it breaks the loop when
> > > > >> the expression <B> is false.
>
> > > > def gen(a):
> > > >     for x in a:
> > > >         if B: break
> > > >         yield x
>
> > > > a_gen = gen(A)
>
> > > > # now iterate over a_gen
>
> > > > --
> > > > Geoff- Hide quoted text -
>
> > > - Show quoted text -
>
> > In your original, you have:
>
> > > l = range(6)
> > > [1 if b!=4 else l.__delslice__(0,len(l)) for b in l][:-1]
>
> > You may be hyperextending the use of '..if..else..', which is one of
> > my fears regarding 'with x as y'.  "l.__delslice__(0,len(l))" is not
> > an expression.- Hide quoted text -
>
> - Show quoted text -

Functional programming is really important to a former professor of
me.  I like to say that None returns as a value.  I think you can call
functional "evaluational".



More information about the Python-list mailing list