A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-March/062142.html below:

[Python-Dev] "as" mania

[Python-Dev] "as" mania [Python-Dev] "as" maniaGeorg Brandl g.brandl at gmx.net
Tue Mar 7 18:54:17 CET 2006
Alex Martelli wrote:

> I think the best use cases for 'assignment inside an if or while'  
> condition, as far as they go, require `capturing' a SUB-expression of  
> the condition, rather than the whole condition.  E.g., in C,
> 
> while ( (x=next_x()) < threshold ) ...
> 
> being able to capture (by `as') only the whole (true or false)  
> condition meets a minority of the use cases, so I'm unenthusiastic  
> about it.

There are use cases (because every value can be tested for true-ness), such
as the likes of

while file.readline() as line:
    BLOCK

(which is not needed for builtin file objects, I know)

or something like

m = re.match(...)
if m.group(1) as filename:
    do something with filename


Georg

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4