[Tutor] For-else... Any other handy constructs hiding in Python?

Alan Gauld alan.gauld at yahoo.co.uk
Fri Jun 24 15:10:23 EDT 2016


On 24/06/16 14:07, Alex Hall wrote:

> but I never knew for-else was available. 

for-else is useful although I don't like else for it, I would have
preferred something like for-also as being more meaningful.

> Are there other constructs that I may have missed

Probably. :-)
Are you aware of try-else?
It's not often seen and never strictly needed but it does
sometimes make the code intention clearer.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list