[Python-ideas] "While" suggestion

Ron Adam rrr at ronadam.com
Tue Jul 29 19:49:52 CEST 2008



Andrew Akira Toulouse wrote:
> 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...


How about something liter, like a function that searches containers in a 
way similar to how Yahoo searches are expressed.  While this can be done 
with regex expressions, they aren't something you want to expose to a 
typical user.

It would be a good candidate for a separately developed module that may 
could be included in the library at some point in the future.

Ron




> On Tue, Jul 29, 2008 at 3:15 AM, Roman Susi <rnd at onego.ru 
> <mailto: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 <mailto:Python-ideas at python.org>
>      > http://mail.python.org/mailman/listinfo/python-ideas
>      >
>      > !DSPAM:488e7c4d23202007710671!
>      >
> 
>     _______________________________________________
>     Python-ideas mailing list
>     Python-ideas at python.org <mailto:Python-ideas at python.org>
>     http://mail.python.org/mailman/listinfo/python-ideas
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas



More information about the Python-ideas mailing list