syntax difference

Chris Angelico rosuav at gmail.com
Mon Jun 18 15:42:14 EDT 2018


On Tue, Jun 19, 2018 at 5:26 AM, Rick Johnson
<rantingrickjohnson at gmail.com> wrote:
> On Monday, June 18, 2018 at 12:46:36 PM UTC-5, Chris Angelico wrote:
>
>> What about assertions? Are they comments too? Should we
>> have, for instance:
>>
>> if x > 0:
>>     ...
>> elif x < 0:
>>     ...
>> else:
>>     #assert: x == 0
>>     ...
>>
>> or is it better to use an 'assert' statement? After all,
>> they can legitimately be ignored by the interpreter.
>
> (oh my!)
>
> Of course they can "easily be ignored",
>
> for cryin' out loud,
>
> assert statements all begin with the same "syntactical
> tag"!
>
> okay, wait for it...
>
> --> assert <--
>     ^^^^^^
>
> Yep!
>
> Which BTW is a _keyword_.
>
> (if you didn't know that already) *wink*
>
> But please Chris, feel free to bring us your next logical
> dead end.

Ahh, yes, it's easy to find the end of an assert statement, too, isn't
it? Or are you talking about properly parsing, which - as you
miiiiight recall - was my original point?

assert """
"""", ", ";print('Will I print?');\
"';print("Or will I?");\
';print("What about me?");'''\
print("And me? Where endeth");"""\
print('the assertion?');\''''

So easy to take shortcuts. So easy to get bitten. Isn't it nice how
Python provides proper parsing as a module, though? Except that, oh
how terrible, that makes it just as easy to find ALL syntactic
elements.

ChrisA



More information about the Python-list mailing list