(Re-sending to list instead of just to Alex.)

Alex,

Are you aware of these?
- try ... finally
- try ... except ... else
- continue
- break
- with
- @decorator
- x = a if b else c
   -- Like the ternary operator a?b:c in other languages
- x = a or b
  -- Assigns a, defaulting to b if a is false, unlike other
       languages that might assign True or False
  -- Short than the equivalent: x = a if a else b

Any other cool tricks out there, anyone?
--Fred
------------------------------------------------------------------------
Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.
------------------------------------------------------------------------

On 6/24/16 9:07 AM, Alex Hall wrote:
Hey all,
I was looking at how to make my different jobs retry themselves, and found
the for-else construct. I know loops, comprehensions, ifs, and the like,
but I never knew for-else was available. Are there other constructs that I
may have missed--shortcuts or seemingly odd pairings of control statements
like this? Python has a lot of really cool shortcuts and features, like
get/hasattr, the yield keyword, or comprehensions. I always like finding
more to add to the toolbox.


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to