+14
-1
lines changedFilter options
+14
-1
lines changed Original file line number Diff line number Diff line change
@@ -250,7 +250,8 @@ expressions are evaluated lazily. By comparison, several of the ad-hoc
250
250
alternatives listed above must (by the nature of functions) evaluate their
251
251
default values eagerly. The preferred form, using the colon, parallels
252
252
try/except by using "except exception_list:", and parallels lambda by having
253
-
"keyword name_list: subexpression". Using the arrow introduces a token many
253
+
"keyword name_list: subexpression"; it also can be read as mapping Exception
254
+
to the default value, dict-style. Using the arrow introduces a token many
254
255
programmers will not be familiar with, and which currently has no similar
255
256
meaning, but is otherwise quite readable. The English word "pass" has a
256
257
vaguely similar meaning (consider the common usage "pass by value/reference"
@@ -271,6 +272,18 @@ with multiple except/if or with the existing if/else, or a combination.
271
272
Using the preferred order, subexpressions will always be evaluated from
272
273
left to right, no matter how the syntax is nested.
273
274
275
+
Keeping the existing notation, but shifting the mandatory parentheses, we
276
+
have the following suggestion::
277
+
278
+
value = expr except (Exception: default)
279
+
value = expr except(Exception: default)
280
+
281
+
This is reminiscent of a function call, or a dict initializer. The colon
282
+
cannot be confused with introducing a suite, but on the other hand, the new
283
+
syntax guarantees lazy evaluation, which a dict does not. The potential
284
+
to reduce confusion is considered unjustified by the corresponding potential
285
+
to increase it.
286
+
274
287
275
288
Example usage
276
289
=============
You can’t perform that action at this time.
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