[Python-ideas] "While" suggestion
Andrew Akira Toulouse
andrew at atoulou.se
Tue Jul 29 18:55:05 CEST 2008
Point taken -- it's a very valid point, but at the same time building an
unnecessary list isn't really all that good-looking. Being able to do
query-like things is very useful, and I'd prefer to do it as close to the
Python core as possible, rather than (for example) creating a in-memory
sqlite database or something. LINQ, I think, somewhat validates this point
of view. I feel that an integrated way to query data would be a useful
addition. List comprehensions seem to be the natural Pythonic way to do
this, but if you can think of something better...
On Tue, Jul 29, 2008 at 3:15 AM, Roman Susi <rnd at onego.ru> wrote:
> hi!
>
> Jacob Rus wrote:
> > Andrew Akira Toulouse wrote:
>
> ...
>
> > Personally, I'd rather have this broken up than in one gigantic line
> > that looks like:
> >
> > result = [int(line) for line in f if evenP(int(line))
> > until int(line) == 0 with open(filename) as f]
>
>
> I have not followed the thread, but the line above looks cool and
> terrible at the same time.
>
> I can't think what other operator can be squeezed into expression, maybe
> try-except, eh?
>
> result = [int(line) for line in f try if evenP(int(line))
> until int(line) == 0 except ValueError("blabla")
> with open(filename) as f]
>
>
> I am not sure if this kind of SQLness should enter Python syntax at all...
>
> Regards,
> Roman
>
> >
> > As for:
> >
> >> tokenchecks = [token for regex,token in match_tok until
> >> regex.match(s)] return tokenchecks[-1]
> >
> > This is much more readably expressed as:
> >
> > for regexp, token in match_tok:
> > if regexp.match(s):
> > return token
> >
> >
> > Cheers,
> > Jacob Rus
> >
> > _______________________________________________
> > Python-ideas mailing list
> > Python-ideas at python.org
> > http://mail.python.org/mailman/listinfo/python-ideas
> >
> > !DSPAM:488e7c4d23202007710671!
> >
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20080729/947196c6/attachment.html>
More information about the Python-ideas
mailing list