FAQ
This is more of a curiosity question then anything else... I was just
wondering why in version 3 of python assertions weren't converted to
use parenthesis, since print was.

I am just asking because it seems the following line of code would
seem more readable as a function:
assert 2 + 2 == 5, "Only for very large values of 2."

Search Discussions

  • Mark Dickinson at Aug 20, 2010 at 7:27 am

    On Aug 20, 6:13?am, genxtech wrote:
    This is more of a curiosity question then anything else... ?I was just
    wondering why in version 3 of python assertions weren't converted to
    use parenthesis, since print was.

    I am just asking because it seems the following line of code would
    seem more readable as a function:
    ? ?assert 2 + 2 == 5, "Only for very large values of 2."
    Well, part of the idea of asserts is that when you're running with
    optimizations turned on (python -O), asserts should be disabled. But
    if assert were a normal function then in

    assert(expensive_check)

    the argument expensive_check would be evaluated both with 'python' and
    with 'python -O'.

    --
    Mark

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedAug 20, '10 at 5:13a
activeAug 20, '10 at 7:27a
posts2
users2
websitepython.org

2 users in discussion

Mark Dickinson: 1 post Genxtech: 1 post

People

Translate

site design / logo © 2022 Grokbase