Liste des Groupes | Revenir à cl misc |
On 03/04/2024 02:23, Lawrence D'Oliveiro wrote:On 2 Apr 2024 08:26:14 GMT, Stefan Ram wrote:>
ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:It’s bloody horrible Python even when wrapped correctly. I think
>def diff( x ):>
return 1 if x == 'x' else 0 if type( x )is str else[ 'sum', diff( x[
1 ]), diff( x[ 2 ])]
if x[ 0 ]== 'sum' else None
Oops! That was one long line starting with "return";
it was wrapped by the newsreader, but is not correct Python anymore
when wrapped this way.
Python’s version of the conditional expression is a complete
abortion.
That's probably the reason almost no one uses it. That post is the
first time I have ever seen conditional expressions outside of a brief
mention in a tutorial on Python conditionals showing how to write
normal conditionals in the language. I think Python stole this one
from Perl.
Les messages affichés proviennent d'usenet.