Re: Implicit conversion to boolean in if and while statements

Discussion in 'Python' started by Stefan Behnel, Jul 15, 2012.

  1. Andrew Berg, 15.07.2012 10:34:
    > This has probably been discussed before, but why is there an implicit
    > conversion to a boolean in if and while statements?


    There isn't. This has nothing to do with "if" or "while".

    All objects have a truth value in Python, evaluating to True by default
    (object), unless they implement the test themselves.

    As Chris said, very convenient.

    Stefan
    Stefan Behnel, Jul 15, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. J Leonard
    Replies:
    4
    Views:
    12,668
    Mark Space
    Jan 19, 2008
  2. John Crichton
    Replies:
    6
    Views:
    261
    John Crichton
    Jul 12, 2010
  3. Metre Meter
    Replies:
    7
    Views:
    366
    Metre Meter
    Aug 6, 2010
  4. Andrew Berg
    Replies:
    143
    Views:
    1,395
    Chris Angelico
    Feb 16, 2013
  5. Chris Angelico
    Replies:
    0
    Views:
    197
    Chris Angelico
    Jul 15, 2012
Loading...

Share This Page